From patchwork Wed Jan 31 10:57:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1807043dyb; Wed, 31 Jan 2024 03:02:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPTrNPcFGTCu2OT7jkLESBKBAraLWJs3RDMN8Zgw1cc0aSROExMjpR3jbqjqquBHvhaNzj X-Received: by 2002:a05:622a:20a:b0:42b:ef3f:1d83 with SMTP id b10-20020a05622a020a00b0042bef3f1d83mr26996qtx.29.1706698926836; Wed, 31 Jan 2024 03:02:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706698926; cv=pass; d=google.com; s=arc-20160816; b=YPKW38m5uN3oNjIQaAPrFQi+hglBCQEdRi+74rson0Sqb2+zeKHFnpJt2sxHTWocEW A9xqTm4svKilZ1Ntdj3C39Q+46fZVRRXaN2rNVyEsPv10m+MRfwrabA107vxPNkdVY6E /vps57UIcoN5zWaKFgHaNlPtkqNX2XOa8xjHzUl/CseykJujBqwZh/HFeIHhDhsknVI3 +mzPYQytKI9au8Y7UtSn3E6kgOxHBmt0fQPgqNWCWNxixt0YmxR7URbTdkwkVw+z+9f0 TrRalb3RQznr7TZ7KsDLY9Kf9EZ3E3O3uW4amRx7/DbrvKaiWc0TzsM9LvawukMzPMk3 FLRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2GpWOaEgIE3YdqJG72nWm6qdSaD5DSuDXkli/E5CAcs=; fh=0M43LspzcEYWZfrlGNkYalXHEXfTR/H7h1M1jmCxJqg=; b=xmtU8h8oXwPK9dzaEn90kdLULAoL62C2vOduJF+G9CgLUXVDpFyQqz8SEUfWK/7z0+ m8v+eraKxtq/0NQBI5sWVVweu1H8U1UZG/qHj5Qh/gPcV1vjgOXsgsQN/IrcW1VGfUHi st2FaRKK1Oo6V4L0Y+WwXXqEcwpaBibSQXmJ+uLh37dcDjg90L22Ur0JQTefaSTCrmig Sdon6HVgehNhkubahMJRxaP30Lky1QuzunukhMxVUYCEkvVY1sFiEMmSBWAMelsbFd9V qUWCeuQzt5uZ89nFingwolP7P5aUIlDDU3g/+2MOSXTtz5FFS+aE9vkyCY2WAuC0dBXs DLvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SoLrh1dF; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46286-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46286-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCUCJfFt05HdXJ5zrNsmjPQQSGs4wmXj0sQbYj6zW17P+iFNXD3Pe6P3sZIZ1q9a/cZIXO6ic/YaAPv0TfgXL3NtZ/x/EQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n6-20020a05622a040600b004299526a77dsi11913302qtx.792.2024.01.31.03.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:02:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46286-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SoLrh1dF; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46286-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46286-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C03C71C24D55 for ; Wed, 31 Jan 2024 11:00:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B703779933; Wed, 31 Jan 2024 10:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="SoLrh1dF" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 525DD6DD1E; Wed, 31 Jan 2024 10:58:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698709; cv=none; b=KQHMMC7uWHVbiFc8BLNQ1xsBgBdcCq00lNtkCjGXlA+9whhTmsAbVgu68cNhBRaOV+bVlo5xqSVPOwY4S0abZG7uMjUtP9h089qRS0zyoyHjKvvQje4MCEOSP+d3qgXnHSZnIE81tt7YLmSF57jbD+tgaEMwt1iv3ms6rGcbRZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698709; c=relaxed/simple; bh=bW9yBz0oyR3w0RlViIUq4vhgeR4ugr+YwXZ3aG+gPu0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q9m3L2dd7MjkmTPR9Y0q9nxhkJowFcFqF0zCVcINc70LyzbcldtY5EoUQFF/rBUSKqoON0MZYSxDD5XasdE2kOHz3wnJv3C0fXVyBWpek+twv337afa9g3VKfwq5nOu7ITUm1Xk9EvDdq5lTUNRhfDCfkfWcrDsQQDtmLsqXn3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=SoLrh1dF; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V78FqF004999; Wed, 31 Jan 2024 10:58:07 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-transfer-encoding:content-type; s= qcppdkim1; bh=2GpWOaEgIE3YdqJG72nWm6qdSaD5DSuDXkli/E5CAcs=; b=So Lrh1dFlUx8HwmG+OCwLkW0ZesTAD7roLQZ+9OdX4rhQhSciFDFz2DrV8O28fSVf+ ARaaCk+aAkBipjf1GdJB7f/wOKLbCeLrPR6AFbrnFoQO5OE6iYPjUC/zS9L/zhPT wMOhw4N/9nd6IkbKLWiwdOp1LKQu++XRuLqigL61ZMh3XCrlMiJ2hcpim1W3KSPm zaccO5dAtobX/v/b6XMxlHALIDHOYawcbHK5n7TuM8pPfz/6KR+6hA8sD4PapAyi ifho4SLyXhoe44orhui6UBmgefPC0NsRbdblv1G/AZ4ure1v1h9NM4Z6Buz75PIp VUJXwMoTYkz5P0QbbFcQ== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyfc8rxn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:06 +0000 (GMT) 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 40VAw5SX011618 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58: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.1118.40; Wed, 31 Jan 2024 02:57:59 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha , Bagas Sanjaya Subject: [PATCH v8 01/10] docs: qcom: Add qualcomm minidump guide Date: Wed, 31 Jan 2024 16:27:25 +0530 Message-ID: <20240131105734.13090-2-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: WL28ghXWoboFz7W1bn2Wut7_F7XYGLuG X-Proofpoint-ORIG-GUID: WL28ghXWoboFz7W1bn2Wut7_F7XYGLuG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603533661592435 X-GMAIL-MSGID: 1789603533661592435 Add the qualcomm minidump guide for the users which tries to cover the dependency, API use and the way to test and collect minidump on Qualcomm supported SoCs. Signed-off-by: Mukesh Ojha Reviewed-by: Bagas Sanjaya --- Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/qcom_minidump.rst | 318 ++++++++++++++++++++ 2 files changed, 319 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 fb40a1f6f79e..edab05fc4653 100644 --- a/Documentation/admin-guide/index.rst +++ b/Documentation/admin-guide/index.rst @@ -121,6 +121,7 @@ configure specific aspects of kernel behavior to your liking. pm/index pmf 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..2a057612422b --- /dev/null +++ b/Documentation/admin-guide/qcom_minidump.rst @@ -0,0 +1,318 @@ +Qualcomm Minidump Feature +========================= + +Introduction +------------ + +Minidump is a best effort mechanism to collect useful and predefined +data for post-mortem debugging on a Qualcomm System on chip(SoCs). + +Minidump is built on the premise that a hardware or software component +on the SoC has encountered an unexpected fault. This means that data +collected by Minidump can not be assumed to be correct or Minidump +collection itself could fail. + +Qualcomm SoCs in engineering mode provides mechanism for generating +complete RAM dump for both kernel/non-kernel crashes for postmortem +debugging however, on a end user product taking complete RAM dump at +the time of failure has substantial storage requirement as well as it +is time consuming to transfer them electronically. To encounter this +problem, Minidump was introduced in Qualcomm boot firmware that provides +a way to collect selected region in the final RAM dump which is less +in size compared to complete RAM dump. + +Qualcomm SoCs contains Application Processor SubSystem(APSS) and its +co-processor like Audio Digital Signal Process(ADSP), Compute DSP(CDSP), +MODEM running their operating system or firmware can register their +selected region in their respective table called SubSystem table of +content (SS-ToC) and the addresses of these tables is further maintained +in a separate table called Global Table of Content (G-ToC) inside separate +region maintaied inside RAM called Shared memory(SMEM). More about shared +memory can be found inside ``driver/soc/qcom/smem.c`` under doc section +and it is briefly discussed in later section. + +It is to note that SubSystems, Remote processors and co-processors have +same meaning in this document and been used interchangeably. + +High level design +----------------- +:: + + +-----------------------------------------------+ + | RAM +-------------+ | + | | 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 +SSX-ToC: SubSystem X table of contents + X is an integer in the range of 0 to 10 + Older boot firmware has kept this limit to 10 + however, in newer firmware this number is expected to change + +SSX-MSn: SubSystem memory segments numbered from 0 to n + For APSS, n is limited to 200 from older boot firmware + + Older boot firmware statically allocates 300 as total number of + supported region across all SubSystem in Minidump table out of + which, APSS limit is kept to 201. In future, this limitation + from boot firmware might get removed by allocating the region + dynamically. APSS Minidump kernel driver keeping this limit to + 201 to be compatible with older boot firmware. + +SMEM is a section of RAM reserved by boot firmware and is the backbone of +Minidump functionality to work. It is also a medium of inter processor +communication and a way where boot firmware can prepare something for +upcoming operating system usage. + +Qualcomm SoCs boot firmware must reserve an area of RAM as SMEM prior to +handling over control to the run-time operating system. It creates SMEM +partition for Minidump with ``SBL_MINIDUMP_SMEM_ID`` and creates an array +of pointers called Global table of content (G-ToC) at the start of this +partition. Each index of this array is uniquely assigned to each SubSystem +like for APSS it is 0 while for ADSP, CDSP, MODEM it is 5, 7 and 3 respectively. +points to their table of segments called SS-ToC to be included in the Minidump. + +From the diagram above, Global Table of Contents (G-ToC) enumerates a fixed +size number of SubSystem Table of Contents (SS-ToC) structures. Each +SS-ToC contains a list of SubSystem Memory Segments which are named +according to the containing SS-ToC hence, SSX-MSn where "X" denotes the +SubSystem index of the containing SSX-ToC and "n" denotes an individual +Memory segment within the SubSystem. Hence, SS0-MS0 belongs to SS0-ToC +whereas SS1-MS0 belongs to SS1-ToC. Segment structure contains name, +base address, size of a Segment to be dumped. + +The Application Processor SubSystem (APSS) runs the Linux kernel and is +therefore not responsible for assembling Minidump data. One of the other +system agents in the SoC will be responsible for capturing the Minidump +data during system reset. Typically one of the SoC Digital Signal +Processors (DSP) will be used for this purpose. During reset, the DSP will +walk the G-ToC, SSX-ToCs and SSX-MSns either., dump the regions as binary +blob into storage or pushed outside to the attached host machine via USB +(more described in Dump collection section below). + +Qualcomm Remote Processor Minidump support +------------------------------------------ + +Linux Kernel support recovery and coredump collection on remote processor +failure through remoteproc framework and in this document, remote processors +meant for ADSP, CDSP, MODEM etc. Qualcomm remoteproc driver has support for +collecting Minidump for remote processors as well where each remote processor +has their unique statically assigned descriptor in the G-ToC which is +represented via ``minidump_id`` in ``driver/remoteproc/qcom_q6v5_pas.c`` +and it helps getting further information about valid registered region from +firmware and later collecting via remoteproc coredump framework. + +Qualcomm APSS Minidump kernel driver concept +-------------------------------------------- + +Qualcomm APSS Minidump kernel driver adds the capability to add Linux +region to be dumped as part of Minidump collection. Shared memory +driver creates platform device for Minidump driver and on Minidump +driver probe it gets the G-ToC address (``struct minidump_global_toc``) +by querying Minidump SMEM ID ``SBL_MINIDUMP_SMEM_ID`` as one of parameter +to ``qcom_smem_get`` function. Further, driver uses APSS Minidump unique +descriptor or index i.e., 0 to get APSS SubSystem ToC and fills up the +fields of ``struct minidump_subsystem`` and allocates memory for Segment +array of structure ``struct minidump_region`` of size compatible with +boot firmware (default size is 201). This really means that total 201 +APSS regions can be registered for APSS alone and the Minidump kernel +driver provides ``qcom_minidump_region_register`` and +``qcom_minidump_region_unregister`` function to register and unregister +APSS minidump region. Example usage explained in later section. + +To simplify post-mortem debugging, APSS driver registers the first region +as an ELF header that gets updated each time a new region gets registered. +and rest 200 region can be used by other APSS Minidump driver client. + +The solution supports extracting the Minidump produced either over USB +or stored to an attached storage device, if not configured default mode +is USB more described in Dump collection section. + +How a kernel client driver can register region with minidump +------------------------------------------------------------ + +A client driver can use ``qcom_minidump_region_register`` API's to register +and ``qcom_minidump_region_unregister`` to unregister their region from +minidump driver. + +A 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. + + .. 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; + } + + [...] + + +Testing +------- + +Existing Qualcomm SoCs already supports collecting complete RAM dump (also +called full dump) can be configured by writing appropriate value to Qualcomm's +top control and status register (tcsr) in ``driver/firmware/qcom_scm.c``. +Complete RAM dump on system failure is where entire RAM snapshot is pushed out +to Host computer attached to SoC via USB similar to one of the way will be +used for Minidump described later in Dump collection section. Complete RAM +dump entirely get controlled from Qualcomm boot firmware and is not related +to Minidump or SMEM except the fact that same register is used to configure +one of the mode. + +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>; + }; + + [...] + }; + [...] + + }; + +A kernel command line parameter is provided to facilitate selection of +dump mode also called download mode. Boot firmware configures download +mode to be full dump even before Linux boots up however, one need to pass +``qcom_scm.download_mode="mini"`` to switch the default download mode +to Minidump. Similarly ``"full"`` need to be passed to set the download +mode to full dump and passing ``"full,mini"`` will set the download mode +where both Minidump along with fulldump will be collected on system failure +however, this mode will only work if dump need to collected via USB more +about this described in Dump collection section. + +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 the set download mode. + +Dump collection +--------------- +:: + + +-----------+ + | | + | | +------+ + | | | | + | | +--+---+ Product(Qualcomm SoC) + +-----------+ | + |+++++++++++|<------------+ + |+++++++++++| usb cable + +-----------+ + x86_64 PC + +The solution supports a product running with Qualcomm SoC (where minidump) +is supported from the firmware) connected to x86_64 host PC running PCAT +tool. It supports downloading the minidump produced from product to the +host PC over USB or to save the minidump to the product attached storage +device(UFS/eMMC/SD Card) into minidump dedicated partition. + +By default, dumps are downloaded via USB to the attached x86_64 PC 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 product 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 Jan 31 10:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1809184dyb; Wed, 31 Jan 2024 03:05:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZbhEC/Kle+CTPiR4kGTUVf9R4JJXvCH7u8xZbw5sti2lgw9I5BDKvLkEzlfAfJznebqNR X-Received: by 2002:a05:6870:89a4:b0:218:6d38:1634 with SMTP id f36-20020a05687089a400b002186d381634mr1534967oaq.3.1706699129611; Wed, 31 Jan 2024 03:05:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699129; cv=pass; d=google.com; s=arc-20160816; b=o/e3Dp9pBui7M24DFmzU5tFn/gR6QZsgicZpmbZjr3UTaN8m6F55cwt9SSu9r0TyKX jIhngJmzwmd7qQK3UrDt7gaSgkh6WH2LXXorP2oV+keCBoeLiPvu5L0ZIGaBj0GDb41J XTxpTEm9FOxu73XMw84oxhsYkSzuxrjqOscynP4a3t0g9fAqNWQ2MKxlTL/f0Zcieyb6 PedJYC442vWD4a4acDqayQxGPcUpzWG9H7nJyyE7ewQyZVoyjA3fBpYHrXPr5QEzbD8K ddyrpSNh3qFFNCupQS6acGJoeicDD0kHVDH+begDhPhDv674psH1bnj6lGUkepksZhgi Japg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2nwuSUUya5Pmo11oGL6x4RKwwnnd1qGdMvMXWMYo8aQ=; fh=ym59cZBhTlpB5dyX9cwYZnC0/s4SFEhqZ6LCZSNsxEE=; b=SupmrV2kOLK9mliExX6/HLvi3VCQqEHJMIjyLwbMkb9GT2xwy9SjpRByCXzk/JouTP 8ALLoNYZqf3/7N39vemc/rwXKTX7wQNSPUmjXddBaaKgGyf0w5/CIXrhXN4DnzFseRvE KluJIMvmcxyxQyjVLQ+P/PPqio5ljJmaSRDxAq3/DNSkyUtBRugjTaRn8XitqdoORxMa n8BYcmaYpKEo4b9fzPx+EribsEKJ0oT4sRWcmxQijKi+tnDR0qVNEUBMIFaXOW52vMse PMmLtz+fPBv6A3cuAksaf+1j+yN2RWo00ezqTMc5ZOOeG9lCc+AZfLDar2BAFKBO8vMW 0HvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=f+6I896R; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46287-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46287-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCUkQBFM7Agzk6piVdQjxaYJT0WMw8Pxx65q31eBcxgFuUIBDwQ+XQXTGzeBdv2dOKkAUZuZKzyqySFWYYmw5Jw747X+Jw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n29-20020a638f1d000000b005cdfaea88adsi9101194pgd.774.2024.01.31.03.05.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:05:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46287-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=f+6I896R; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46287-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46287-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B0C54294BDD for ; Wed, 31 Jan 2024 11:00:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FCEF745E7; Wed, 31 Jan 2024 10:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="f+6I896R" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FA7378B68; Wed, 31 Jan 2024 10:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698713; cv=none; b=lK8smv7e2fzDRan4KfaAvU7vJ/wd+a+uEWiGvyf9/2cJ8uZlY7oGDQVLc/c5XdqEbatk8bIqzUJ4dhRVGFKZAlCnPz3jVuL2/FXJVyuYBhPTxpXADBLZ5UK9YJ7BU3mswgciw0k60yHdWwfV46wiQi8fZqAZX9LmvVamoSn7dPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698713; c=relaxed/simple; bh=Xqy52vIcvXJeRMiKzcF+4BdYl08rCg9Lk7j3OSFo49o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JNsVT6jegYkVfO0JXqZA1Dw6Rz+mCJ8rNTli9aXmqx1IYP/mLp2LtaweXJsTCHb+mPyZjZSDtqnlOmEdc0inoqOKSX/hasXnJCRCch2jDWSJ+paSOld5+UNzqDD55ATN8jX4UjDCHIc5zK5bQonTxfadm2zA0kuCzaUGgjPZTZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=f+6I896R; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V78FqG004999; Wed, 31 Jan 2024 10:58:12 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-transfer-encoding:content-type; s= qcppdkim1; bh=2nwuSUUya5Pmo11oGL6x4RKwwnnd1qGdMvMXWMYo8aQ=; b=f+ 6I896RTwf6eWG7OxXrdzRRlDEC82bIqab4RABrV7Lv7kt1I40WgsroxkCEtuYvGq cg/9l0TKc2FokTXIlHQwn0VASPNRoEnhOgD+CRPOvcMP6446e2fBigNxwF/pai5t e0fk3jrQhxElzyDlLLw1Iq7f79xps58y5DbShTEsGI3gfoS1clOLECOEsHTzrxdA Dz56cWQbyflGVg3gUyij2YKoVL8U8/YSNhrVXa8r70ufcjX+LSllT01qM5WP+VJo YBro34+5OFM3dRaPgrsSNkJZBRui53JLBCRcmzTXmhKuSant2KjFuFq6CQju2D/T b1GZeSHy3XHuJho44Y/g== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyfc8rxnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:12 +0000 (GMT) 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 40VAwB6a017574 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:11 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.1118.40; Wed, 31 Jan 2024 02:58:05 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 02/10] soc: qcom: Add qcom_rproc_minidump module Date: Wed, 31 Jan 2024 16:27:26 +0530 Message-ID: <20240131105734.13090-3-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: YOFO1PEOa0_xcV3gRxdKoQFGUBxR6j97 X-Proofpoint-ORIG-GUID: YOFO1PEOa0_xcV3gRxdKoQFGUBxR6j97 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603746767532798 X-GMAIL-MSGID: 1789603746767532798 Add qcom_rproc_minidump module in a preparation to remove minidump specific code from driver/remoteproc/qcom_common.c and provide needed exported API, this as well helps to abstract minidump specific data layout from qualcomm's remoteproc driver. It is just a copying of qcom_minidump() functionality from driver/remoteproc/qcom_common.c into a separate file under qcom_rproc_minidump(). Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/Kconfig | 10 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_minidump_internal.h | 64 +++++++++++++ drivers/soc/qcom/qcom_rproc_minidump.c | 111 ++++++++++++++++++++++ include/soc/qcom/qcom_minidump.h | 23 +++++ 5 files changed, 209 insertions(+) create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h create mode 100644 drivers/soc/qcom/qcom_rproc_minidump.c create mode 100644 include/soc/qcom/qcom_minidump.h diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index c6ca4de42586..33584bbbfc0e 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -268,4 +268,14 @@ config QCOM_INLINE_CRYPTO_ENGINE tristate select QCOM_SCM +config QCOM_RPROC_MINIDUMP + tristate "QCOM Remoteproc Minidump Support" + depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SMEM + help + Enablement of core Minidump feature is controlled from boot firmware + side, so if it is enabled from firmware, this config allow Linux to + query predefined Minidump segments associated with the remote processor + and check its validity and end up collecting the dump on remote processor + crash during its recovery. endmenu diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index 9268e15e1719..fa685e5a12a6 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -35,3 +35,4 @@ 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_RPROC_MINIDUMP) += qcom_rproc_minidump.o diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h new file mode 100644 index 000000000000..71709235b196 --- /dev/null +++ b/drivers/soc/qcom/qcom_minidump_internal.h @@ -0,0 +1,64 @@ +/* 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_ + +#define MAX_NUM_OF_SS 10 +#define MAX_REGION_NAME_LENGTH 16 +#define SBL_MINIDUMP_SMEM_ID 602 +#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) +#define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) +#define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) + +/** + * struct minidump_region - Minidump region + * @name : Name of the region to be dumped + * @seq_num: : Use to differentiate regions with same name. + * @valid : This entry to be dumped (if set to 1) + * @address : Physical address of region to be dumped + * @size : Size of the region + */ +struct minidump_region { + char name[MAX_REGION_NAME_LENGTH]; + __le32 seq_num; + __le32 valid; + __le64 address; + __le64 size; +}; + +/** + * struct minidump_subsystem - Subsystem's SMEM Table of content + * @status : Subsystem toc init status + * @enabled : if set to 1, this region would be copied during coredump + * @encryption_status: Encryption status for this subsystem + * @encryption_required : Decides to encrypt the subsystem regions or not + * @region_count : Number of regions added in this subsystem toc + * @regions_baseptr : regions base pointer of the subsystem + */ +struct minidump_subsystem { + __le32 status; + __le32 enabled; + __le32 encryption_status; + __le32 encryption_required; + __le32 region_count; + __le64 regions_baseptr; +}; + +/** + * struct minidump_global_toc - Global Table of Content + * @status : Global Minidump init status + * @md_revision : Minidump revision + * @enabled : Minidump enable status + * @subsystems : Array of subsystems toc + */ +struct minidump_global_toc { + __le32 status; + __le32 md_revision; + __le32 enabled; + struct minidump_subsystem subsystems[MAX_NUM_OF_SS]; +}; + +#endif /* _QCOM_MINIDUMP_INTERNAL_H_ */ diff --git a/drivers/soc/qcom/qcom_rproc_minidump.c b/drivers/soc/qcom/qcom_rproc_minidump.c new file mode 100644 index 000000000000..9bc84cc2536f --- /dev/null +++ b/drivers/soc/qcom/qcom_rproc_minidump.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ +#include +#include +#include +#include +#include +#include +#include + +#include "qcom_minidump_internal.h" + +static void qcom_minidump_cleanup(struct rproc *rproc) +{ + struct rproc_dump_segment *entry, *tmp; + + list_for_each_entry_safe(entry, tmp, &rproc->dump_segments, node) { + list_del(&entry->node); + kfree(entry->priv); + kfree(entry); + } +} + +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)) +{ + struct minidump_region __iomem *ptr; + struct minidump_region region; + int seg_cnt, i; + dma_addr_t da; + size_t size; + char *name; + + if (WARN_ON(!list_empty(&rproc->dump_segments))) { + dev_err(&rproc->dev, "dump segment list already populated\n"); + return -EUCLEAN; + } + + seg_cnt = le32_to_cpu(subsystem->region_count); + ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr), + seg_cnt * sizeof(struct minidump_region)); + if (!ptr) + return -EFAULT; + + 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); + } + } + + iounmap(ptr); + return 0; +} + +void qcom_rproc_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; + } + + 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; + } + rproc_coredump_using_sections(rproc); +clean_minidump: + qcom_minidump_cleanup(rproc); +} +EXPORT_SYMBOL_GPL(qcom_rproc_minidump); + +MODULE_DESCRIPTION("Qualcomm remoteproc minidump(smem) helper module"); +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..cd87caef919d --- /dev/null +++ b/include/soc/qcom/qcom_minidump.h @@ -0,0 +1,23 @@ +/* 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_ + +struct rproc; +struct rproc_dump_segment; + +#if IS_ENABLED(CONFIG_QCOM_RPROC_MINIDUMP) +void qcom_rproc_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)); +#else +static inline void qcom_rproc_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)) { } +#endif /* CONFIG_QCOM_RPROC_MINIDUMP */ +#endif /* _QCOM_MINIDUMP_H_ */ From patchwork Wed Jan 31 10:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1823336dyb; Wed, 31 Jan 2024 03:36:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGX0J5HKCFvi5YkB7Su7AVry/L0CojUWFF1Girv25fhwntg/r8HS+nenDzvbXSj3jPtXzAq X-Received: by 2002:a92:cd49:0:b0:363:86fd:9673 with SMTP id v9-20020a92cd49000000b0036386fd9673mr1554530ilq.10.1706700961395; Wed, 31 Jan 2024 03:36:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706700961; cv=pass; d=google.com; s=arc-20160816; b=zceKO+10DMoteJEVTbCwtEgrySyWyzlqgMPCs/k/scL6NXKyBJ9E3MgC4h2lIkUZUA SryrN3cl/drf4Kk168x5G3Sc5EFzv9wDHmEN/MdjJpky4W6ysa9DLjngOnZiuHkAdKoK 7RuH8qmofUGz/1FJJZlzpyeAkKhRosazkvLFo3YXj1AGyE1lsZcz6yC8wmVQuLJNl73E rrxkh2fM8WPtlQY2AekNSn6T291Bu3qJ6e8Ys1Dq2PY/sDmG2V2aKKfxYC3KwAa+ct9d iBKJFMzXISdyXsdznIORo7cDwGrDpqpKSWRNDzKOgVVPGSBb6IMRj4PDyhwuEhEcwlQ7 m8nQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+iz/KDghEOECmAX5bp6ac8UBJUPavfQUj6HKKlQ4FLY=; fh=ESbpZCgpzFG/jtjFy/RSB6JJqpnWzpIg0SVzMHmq1aE=; b=K5hXokgxA/WYk4Qw3TRTAXxmQuCAVGYo/DFOUjhht9V54hpyruhgbF1pO+5rncKPS+ OFeLQGUC9+pEL57CNS/uKGQX6V3hMGPx28EuI0PizzncGmdBYYxcPxk2JxHQkywaCdhR Gv0eLHairdZhGBC20+PKaQg1X28MbZESnlRalqlG/0U1iYhbngvvy/hmacnff46lm7zU 55ofdfr46gHlA4rQS11rUtGOcwWwJBPOpz+PviTWK0b9yg+PnlMTHS6iOjSf5+D37YmJ X8fKI8x1QH5rUgc74sHj0qb9slXDKf8rRuWfQ3XD5vb+jLnabkktCTRLsafOhySUzRUK /BFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="LiK3Z/RQ"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46288-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46288-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCU+H7Y3dTZqt6TjHTCiSDY2tzxuFIi0KCUTt/lF08XOk/aEQtRv15vI8QRao7ogqGm8TTYKB/KZs1Gi39hcIAhHw7/c9g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y19-20020a637d13000000b005ce58684c5asi9324852pgc.449.2024.01.31.03.36.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:36:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46288-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="LiK3Z/RQ"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46288-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46288-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E2734B31904 for ; Wed, 31 Jan 2024 11:00:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5156579DC0; Wed, 31 Jan 2024 10:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LiK3Z/RQ" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4EC679953; Wed, 31 Jan 2024 10:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698717; cv=none; b=nnsF6EEAsrptTd+MCqjWNcYkTg7Voyo7GxirQohjUQMpc+zNuK+tne289NB2YXF+Jw2K5y9eKlvyxdfZRPRFlfn5VVRk1dIseSl/dLfMHqxH6HMP8f5Ke9/tugXc3iihFQpno7g+Tg2LOG2HoEeKs2nr06GyPJWIB2j6rM/B0nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698717; c=relaxed/simple; bh=DWW42lRKW8z+XXhJKirfF9qYlmBMqyqEeAo1rAWCeA0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SuhKcmKNO71DkKMZJvGyAVzqAKEbRCntd40eKK0r5gX3/yMpE1gulWVa8kP+NSb901wkBlOMm6zApHF61ijOM6dm/S4mVjHSJhI5sGRU9hPgkxqak8K6R2cOEOsq1mLjLdDYXtOvJ/VCXIZby2Upr2UKV1ZYrRYNefhMGiSfges= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=LiK3Z/RQ; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V77YuF031043; Wed, 31 Jan 2024 10:58:17 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-transfer-encoding:content-type; s= qcppdkim1; bh=+iz/KDghEOECmAX5bp6ac8UBJUPavfQUj6HKKlQ4FLY=; b=Li K3Z/RQcPkYCi9IOuUAJvIB+OVL3zO+q7HfVdzEHAQ3YbNzezJLyLPAKa1tiUHaGf IB79tQkaib8vXeHI3YzM3ng/lAjUPqJnr1Tgkwl13qE3IbMk+hbsF6Sqwn3FBSng nTLJQFAPTNM/iCDGxfuXIpLLFrBCXcw7s5G2VCMQVeDBPr6/rVVdROfWOnqw/UgU Mhxv+UAuVvKOXWzQTgZ0qjy8Vh9WkvqpL70+w/J8BA/zrL0GZIwjo2dsNh3tjwR5 qPzXF3Ds/zcLJvEPJNjeGuK3SZPVIpXkKdEkPHDB83ABlnY5th8wylepPURH3fgt IbxPGvwMHNVMPyBh1/5g== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyfnjrx0x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:17 +0000 (GMT) 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 40VAwG25011908 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58: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.1118.40; Wed, 31 Jan 2024 02:58:11 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 03/10] remoteproc: qcom_q6v5_pas: Use qcom_rproc_minidump() Date: Wed, 31 Jan 2024 16:27:27 +0530 Message-ID: <20240131105734.13090-4-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: W8Y3mGYuADYQl0bG60k9ORCYx8LS7eXP X-Proofpoint-GUID: W8Y3mGYuADYQl0bG60k9ORCYx8LS7eXP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxlogscore=975 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789605667255191719 X-GMAIL-MSGID: 1789605667255191719 Now, as all the minidump specific data structure is moved to minidump specific files and implementation wise qcom_rproc_minidump() and qcom_minidump() exactly same and the name qcom_rproc_minidump make more sense as it happen to collect the minidump for the remoteproc processors. So, let's use qcom_rproc_minidump() and we will be removing qcom_minidump() and minidump related stuff from driver/remoteproc/qcom_common.c . Signed-off-by: Mukesh Ojha --- drivers/remoteproc/Kconfig | 1 + drivers/remoteproc/qcom_q6v5_pas.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 48845dc8fa85..cea960749e2c 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -166,6 +166,7 @@ config QCOM_PIL_INFO config QCOM_RPROC_COMMON tristate + select QCOM_RPROC_MINIDUMP config QCOM_Q6V5_COMMON tristate diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index a9dd58608052..21e2e8eb0b2f 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "qcom_common.h" #include "qcom_pil_info.h" @@ -131,7 +132,7 @@ static void adsp_minidump(struct rproc *rproc) if (rproc->dump_conf == RPROC_COREDUMP_DISABLED) return; - qcom_minidump(rproc, adsp->minidump_id, adsp_segment_dump); + qcom_rproc_minidump(rproc, adsp->minidump_id, adsp_segment_dump); } static int adsp_pds_enable(struct qcom_adsp *adsp, struct device **pds, From patchwork Wed Jan 31 10:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1807264dyb; Wed, 31 Jan 2024 03:02:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNFBRPCDi3bLbujsDkNICE8gn8NWOXq04utacDMyX+hZnwu9v+lxOAIFT5RJ1pDjyb95qF X-Received: by 2002:ac8:7f52:0:b0:42a:aa8e:b7df with SMTP id g18-20020ac87f52000000b0042aaa8eb7dfmr3880297qtk.50.1706698948297; Wed, 31 Jan 2024 03:02:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706698948; cv=pass; d=google.com; s=arc-20160816; b=L2WMxdrlcWWjNdJ0/E9KIaAlKst5W6ya38yN6jcGvgj5czVIcsZodMvwZyoD0Ab3Bi TF3+rJ7TQLJILkGBwIcR1GHp4K5d3wJCVYSVUYs2JQNGXWDcmPKJlD9HwbhXt2MHZthz 3Y7wU/YN+kw+FcorRILtoxTbcNj8xaK10j6MBfwtp34WNlIrGeFwkHQfiDkQ7G/1eSpV 0UJKD+hjFl5B7q08aFfU7YwYrRoCEmQYJRnwIvBuOXCN2/DpEIJUXCcwchPgFPHTfXgq +DaSHD2y/eIsCE5plgmgvqlmQtg/iiSi6SoLztDzCYF7Lq+LCiZDh2SiQRsXOO8iAzCK xaJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=E5ZBEKhML5zzIDJkNKeCZoNN28sYgImgOcEqdeDbsz8=; fh=pgyG+n3EB4AmjMlLPBrnof5RDx8cyO/0F5ji1/Ze4eg=; b=sh3IGwX7JTwuvgWt3HepBs8XjzoDXM4qz6Ru6EGp798BeghsCm1SULkr3VPt9DByBc awVynDKyIvBnfNkiax7JmjfsWLMJ8UcuE5AyxxHP0W0fpjficnYnYn21+eaYUG3GlFR7 R2qLwBws161gkNgWGQgzdyZsf0rR09VubzxQcqan2fYDgjw6m74xZ9icHrv1HqxUGmCm a/aZRzBH5cWW+5e6xDsAwsPtosWqWm7uOwvIedTY4wpBTTsgTKR1abKnriofUKTXs8Gh WZ9b8Tv9FJi42w86tSndm/1VY63l0l1Z+H2I/QxBjbHU5bE2FXz+Ap3NEXgenoh+KwsX 8nOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mQxIKUfs; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46289-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46289-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCUHFfzwuUTWbfuinNYyZJbGx5t1RnHLRP0u5XImo1Mn2JL79Lnjh50ThF9VSSIgwQQMUHdKosIf8YVnXjPGlIpduKVnEA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n6-20020a05622a040600b004299526a77dsi11913302qtx.792.2024.01.31.03.02.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:02:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46289-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mQxIKUfs; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46289-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46289-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B94811C2A570 for ; Wed, 31 Jan 2024 11:00:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7427D7A707; Wed, 31 Jan 2024 10:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mQxIKUfs" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 454A279DC5; Wed, 31 Jan 2024 10:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698722; cv=none; b=HMdGYoGAy1RNXsOh+Bf+hmd3wCyMqEJ8c4lFnsousOR8ij1xgshgdw3EgAjwIDmQAo5IvWp4I7Y1dxbKvV8GAx1o7dxCOnprU9Plw4IyPkh/9ElPTA2JmBB4u9rwQRtH7+IVZd5eu9uneL3vjt/jGT3ByDyuz/EkoC1liHdoJws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698722; c=relaxed/simple; bh=Rj7NwH82VZywGlw+2HspE0bqtshPXHOoPd9clarX4yE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R97tNR4gC0x8mOMpFWXEKuZXVak1K7ipcdsImSCycM1YNrvnDsTW6AKfhV+dCIsjU/InU803WZmRaGP2BsYaYCQs2/EaWVHgo4hHzPaQAQbqLiYgntUQCWDWsw4f8hQmvFIq3kUkOEKXfdrCQP11qYLfJM85HzDIpzu60Cm4FVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mQxIKUfs; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40VAcCiY001645; Wed, 31 Jan 2024 10:58:23 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-transfer-encoding:content-type; s= qcppdkim1; bh=E5ZBEKhML5zzIDJkNKeCZoNN28sYgImgOcEqdeDbsz8=; b=mQ xIKUfslcG6Aa83lUcO15NpJ5mHi7uL4lFbRRQHjTf5C6bXWGefxiEOr0OD4ssZ49 uAAvLcCYURn9Xj+5YFj5yVRsiiQZLRtapbpmRMAKIvjwVdt17Lti7cjkLkbsJTsQ LX5IQwqHrcw6eZjyks4vm/p/AcSCVTkCmEAiR8DcgTr023T4Oo7WQogcjOa/LUDy FkwzWA/u0GZpB3eIPax+JNvxZuiMxHHlNyczn+wi0Xv9M+fqhzko3r72tVSC2nqo Z/nBiXVJdotBeSC91JaRW/V2SUvYz/oeusk6RbTTtcvRX384Z0mp7GGRd/nTFIXe jbT3ANHtWSg91owGEEjA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vy9b8snc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:22 +0000 (GMT) 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 40VAwLaR017669 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:21 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.1118.40; Wed, 31 Jan 2024 02:58:16 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 04/10] remoteproc: qcom: Remove minidump related data from qcom_common.c Date: Wed, 31 Jan 2024 16:27:28 +0530 Message-ID: <20240131105734.13090-5-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: Azmbv-3zXBrosfPN4cMeKEThdT7f8it_ X-Proofpoint-ORIG-GUID: Azmbv-3zXBrosfPN4cMeKEThdT7f8it_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_05,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 clxscore=1015 spamscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310082 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603556374862227 X-GMAIL-MSGID: 1789603556374862227 As minidump specific data structure and functions move under config QCOM_RPROC_MINIDUMP, so remove minidump specific data from driver/remoteproc/qcom_common.c . Signed-off-by: Mukesh Ojha --- drivers/remoteproc/qcom_common.c | 160 ------------------------------- 1 file changed, 160 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 03e5f5d533eb..085fd73fa23a 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "remoteproc_internal.h" #include "qcom_common.h" @@ -26,61 +25,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; @@ -90,110 +34,6 @@ struct qcom_ssr_subsystem { static LIST_HEAD(qcom_ssr_subsystem_list); static DEFINE_MUTEX(qcom_ssr_subsys_lock); -static void qcom_minidump_cleanup(struct rproc *rproc) -{ - struct rproc_dump_segment *entry, *tmp; - - list_for_each_entry_safe(entry, tmp, &rproc->dump_segments, node) { - list_del(&entry->node); - kfree(entry->priv); - kfree(entry); - } -} - -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)) -{ - struct minidump_region __iomem *ptr; - struct minidump_region region; - int seg_cnt, i; - dma_addr_t da; - size_t size; - char *name; - - if (WARN_ON(!list_empty(&rproc->dump_segments))) { - dev_err(&rproc->dev, "dump segment list already populated\n"); - return -EUCLEAN; - } - - seg_cnt = le32_to_cpu(subsystem->region_count); - ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr), - seg_cnt * sizeof(struct minidump_region)); - if (!ptr) - return -EFAULT; - - 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); - } - } - - 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) { - return rproc_coredump(rproc); - } - - if (le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) { - dev_err(&rproc->dev, "Minidump not ready, skipping\n"); - return; - } - - /** - * Clear out the dump segments populated by parse_fw before - * re-populating them with minidump segments. - */ - rproc_coredump_cleanup(rproc); - - 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; - } - rproc_coredump_using_sections(rproc); -clean_minidump: - qcom_minidump_cleanup(rproc); -} -EXPORT_SYMBOL_GPL(qcom_minidump); - static int glink_subdev_start(struct rproc_subdev *subdev) { struct qcom_rproc_glink *glink = to_glink_subdev(subdev); From patchwork Wed Jan 31 10:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1807550dyb; Wed, 31 Jan 2024 03:02:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEb3ZVoz0rltO9/Z9a48czhllasDRCbXy+X8vNYt2hi9oWkXLzM6cSZXpcAtHCcfz7R+J2E X-Received: by 2002:a05:620a:108e:b0:783:e312:b212 with SMTP id g14-20020a05620a108e00b00783e312b212mr1092495qkk.28.1706698974995; Wed, 31 Jan 2024 03:02:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706698974; cv=pass; d=google.com; s=arc-20160816; b=kodFSMRKTBBgYGQGlTrMgTIf1RlSYGy0Ea0w2IsZslL2q0adqx/2tzt9dlW7DR9F+2 /e2cvsAp+BbKTM81+qbV6NKFWZVBGm/hYDB5BK+yiJiFg6NblDQGexm1xZHoKGAa568J XiM8bUiBJsYPl+GQNb2MnB8bon56AIeGOG9yDVyNmSuxA7wcX+nMjjwVuz/FcpGtjR9O QAu4H6sM+cCZQnxxpw1jiDjD+hn+dmrw5haakiUSt71464BIMHECeI6vMvpMlSJIe7b5 OhQGJd6lkfz9zlC18fo7r25ts2crNz8BHgoMxdlZodje3OtJlOiTjedoVt66tEAs+XS8 ydDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=n1PwXNbOSzmmcOnrrXNWhBBczgfzE4P1QBgC2EhbCIs=; fh=6USFI2u/SABVIX3guVCVLAiOGSZNv1eh9g5cqVkw388=; b=zOaQ+1gDm/slAU8Tk8jJjlEUM/tqJd2XPYgHqd3wYCbR/y0XEhHWO46tk1bv+Trv1U bdbOsn02EH4R/Ezc8BDjeTAFr7IoVKSR888plFnxA9vUK7+Zq4yqN0milMzhxSo492Kd MBcm44mVRKyXr7LSiBx6i4dYowTYHyLe6wDowKc+Ngd1hCMBtNY1zNVfjJcCWHdUabAV LZ98+MpRuwpw2uCSc2sKcq/7OIqr72kxUg65hsCiszm1H56I5ost/XpyfaxADj2dNcAZ 5H5Ucl0nI85lG6um3FXwXdV/i3GjFtBNhnd6A6qBn5hnD/VKKC8K/eFJ8oqby2TEhXUe kjTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="D1/7/u8K"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46291-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46291-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCXo5mkiy0BMAofcYWbfWBWIt7GZAu3c/AVvkrVEhgpd3XLtTW4PYUX4nczTkhT7zkphzMGisdk2R/rai2nYDJvowvzwGg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp7-20020a05620a458700b00783f58e515esi8848707qkb.153.2024.01.31.03.02.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:02:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46291-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="D1/7/u8K"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46291-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46291-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0F0F31C2A9A1 for ; Wed, 31 Jan 2024 11:01:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1C867BB10; Wed, 31 Jan 2024 10:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="D1/7/u8K" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C806C7A716; Wed, 31 Jan 2024 10:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698731; cv=none; b=lUXcPfoLwdJpQMk5Tle3YbZtFl5lwIrTDKW8Pb1yYENygZt5MLmeKj4N3uGojAQOovP2MjUtvEsm/MaEGMfSdPZTTn2QzhGRL4tHKCEnU90oY/9L4CtxAdmCNKCsNjwjakDFzG5+H2rVR39rV3dhDaYSf+wsF/mQTUGn1WrXvZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698731; c=relaxed/simple; bh=WV/fdPNH0Zy8bOz53st7fySCJAhuCz2uTpzOhf8G3XU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WcCRJMTABG7gL7HkH+AnVHqpwmVj/aiUA7DDrMcKHClRXV6VyfHkPOZXQ+s8YzbgpyorbdtzJOAxGHUQiqFi7GjqT+W5HAsz8xPhAfKdsr5Cl7kdVLKG+wVwvi0AL0pLEauBvhoOgW3ld0mXKCSez4l/tPqWsjXD/wcKV0EJ68A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=D1/7/u8K; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V77NN8028431; Wed, 31 Jan 2024 10:58:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=n1PwXNbOSzmmcOnrrXNWhBBczgfzE4P1QBgC2EhbCIs=; b=D1 /7/u8KK+TkyObQveTkV62S3HtcgLCFQTijeUivHvEZWdJ/SKpFq8G/hE1lKzLGY2 9ny45zMJ3ShI0OIeSSgXgi6b13z2I3hQyrSZ9q81o7Qv1OySooiCzRuqK2SPpYGg qCt+Tj7syx2DCIZRnCHh7kuoxn/GX6XHW0E17ARHcQBOHrcQri5l0oaasfnNBuK0 ezkga+Rbx0XZtNC73KFVIzx+EX+Nn4TN9su+C29W8fkDeHzCCgkQnbwEuwqa37TX RbzNf8HgB0zKf9ZrSXjv2RvX62+x7NCbJzHxDQRnkWRJrVH6gJc7y88/XssvlkAG Enx7FiaEEADQbtEUt/rA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyfr30wkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:28 +0000 (GMT) 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 40VAwR4w022367 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58: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.1118.40; Wed, 31 Jan 2024 02:58:21 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 05/10] init: export linux_banner data variable Date: Wed, 31 Jan 2024 16:27:29 +0530 Message-ID: <20240131105734.13090-6-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: YJiimOrgVkdV1Mv_l2_p1sZz8VpRKRPd X-Proofpoint-ORIG-GUID: YJiimOrgVkdV1Mv_l2_p1sZz8VpRKRPd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1011 mlxlogscore=999 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603584328742222 X-GMAIL-MSGID: 1789603584328742222 Some debug loadable module like minidump is interested in knowing the kernel version against which it is being build. Let's export linux_banner. Signed-off-by: Mukesh Ojha --- include/linux/init.h | 3 +++ init/version-timestamp.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/linux/init.h b/include/linux/init.h index 58cef4c2e59a..d3d96188551c 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -145,6 +145,9 @@ extern char *saved_command_line; extern unsigned int saved_command_line_len; extern unsigned int reset_devices; +/* Defined in init/version-timestamp.c */ +extern const char linux_banner[]; + /* used by init/main.c */ void setup_arch(char **); void prepare_namespace(void); diff --git a/init/version-timestamp.c b/init/version-timestamp.c index 043cbf80a766..a48f2c19e5d7 100644 --- a/init/version-timestamp.c +++ b/init/version-timestamp.c @@ -6,6 +6,7 @@ #include #include #include +#include struct uts_namespace init_uts_ns = { .ns.count = REFCOUNT_INIT(2), @@ -28,3 +29,4 @@ struct uts_namespace init_uts_ns = { const char linux_banner[] = "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; +EXPORT_SYMBOL_GPL(linux_banner); From patchwork Wed Jan 31 10:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1808333dyb; Wed, 31 Jan 2024 03:04:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGs8cWswexILp3Ig8zBMYzJ7R1IXiTmUw8cjRYcoMrXPMk19Vxlifg4ZJ236qSO57uX7oYw X-Received: by 2002:a05:6402:946:b0:55f:5e7b:7c66 with SMTP id h6-20020a056402094600b0055f5e7b7c66mr765905edz.25.1706699047490; Wed, 31 Jan 2024 03:04:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699047; cv=pass; d=google.com; s=arc-20160816; b=NIj2Z7Auan/kIGXl+o1YrwPP97THHVkorsknRd61jQl1osKCYUm15R2yLP/SAJ7K36 hzMHrEDh7cHWIjWdrfNIOtuv84a9xpt2BBLKg1FbnOtuumBuEZLHeERZFuLMLcM+Vzos WK1Ns5Lm7luyvBluEfMYefGdc13VJxsScZLj/J/spw0nWWkNMLim9yDcYFA3AEkEXvrp anAan73UDy8J6jdaZWTPk4S82WlKDlK+scNYJsXeU+abqMjK52M5D1oY2L/1B4LRuXeN vaK7As4etUI8vJwaWMboEXEX7nr3WwdFPuYukffVRR0JnfryHpdE+6n6c6cAx6jCivyw Xc1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=D/NC7dho3y7ogexkV656rbxpkPdkHfO9t3t2avaYRG4=; fh=QpQoz3LTYB1Jo8R3Sw/aw1GI9qGxiiTrEMhCvGShhWI=; b=knJ/vkEA9mIYPYHAlm1VIgwe4KkARLeYqDkpbhtsFsJ5WqbkB8XPl93NCXRAEsQa4u +D2NCPpjqyz9HQ5Qbgk1vTl1MeSM6fiS/FmYYzhW8CyQU032xHWEw2ZFfDL752hSvJs3 RIf7zlbpOk9q5vna4L89e07MWscYbeC7sg3r8gf+euVwnmpJLQkM9gnAwZEuHSDQG4Q4 I75i13Bpd8tu3tboyL6s2SxJwweerPRKX8JfbYkEWej0q2s117knQzBCamoTTZc61tby IP9vTzookiAgACcG4tjO2aQMGTmtFbZSPYP0Ysjj3lJLR8439b7rQDF2hjxKOT+eeYHQ AWew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lsHGthkP; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46292-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46292-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCUnOCUQw/3K1O4WVSJ6PNT4aMBuPOIJeuA50hoAqKKtEvwn1eponmlr/3WUoBsvy/k9ybJ3OnshfBa2YgyRyDJlB0NQRg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id fd24-20020a056402389800b0055a61376aeesi5550449edb.240.2024.01.31.03.04.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:04:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46292-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lsHGthkP; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46292-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46292-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E49331F2C515 for ; Wed, 31 Jan 2024 11:01:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F264A7D3E6; Wed, 31 Jan 2024 10:59:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lsHGthkP" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEBE27BB06; Wed, 31 Jan 2024 10:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698735; cv=none; b=u02obIM4qK6bKeUKJkrJ2PsR0EAk4BxHrkstzGe+p/NNhvKjYazrznmisOFuJmf1G+i2niUYXpmIopv5kTdW283UF6jrFj5MGXquJUL63txEg6rmXuXYyuokSAiftT8jA1rKJAc8N4tcBLMJbukIMB6bHlRUgoxT8jXE8Pshvag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698735; c=relaxed/simple; bh=vjejlTQRlo736yuEesUJLT7UeehfZ7v8L1NhyeKT8hA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eYuQJQ5idp9nMI/Hlgtd6NkMD0HrnpXNv6xmNB0kVI6DV9KEWmTESgJ5UzG+w1ocdjWNArKZhpxkk01F3pasSJqyzVoPJpo8C5t5lkBFWV9REsqlP2owD/Schm24t3cOQBoH+tsCUfjeqASNFGLkd1jLEm8yY0jaNfVJW3yozbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=lsHGthkP; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V76nY5028046; Wed, 31 Jan 2024 10:58: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-transfer-encoding:content-type; s= qcppdkim1; bh=D/NC7dho3y7ogexkV656rbxpkPdkHfO9t3t2avaYRG4=; b=ls HGthkPi42cw9fbshHDTR0A/Hmi9o2OQOsZJr2Wkkkp0xdPjnaMtLHprmj/Kzu9pl nodmfj34vMQHeDT36cTWoNtOxtgOjLm2viaJKvEVA2TIAl7cOZnk82YxA1oR0Aln c4/6DOlt3v6xJxioUVDc/DrOCL/YE0QgKOERoUdn6u5uf28yv4tMaTW3eG8Ze9o9 bm0BmRhRxQzB2r5r1TZ1tW3/2rGhPlBxM9pYt3At7dldRNxs/iMhtfJGAcGaYZJt n4/qNbRO2y/xFBMMwyCWczMvt4EQra9upgRPnomSGH5DLD1PSQCoqlg+j2twsYVa MtVDcIYz27aP752uXwBw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyfnjrx1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:34 +0000 (GMT) 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 40VAwXEo022404 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58: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.1118.40; Wed, 31 Jan 2024 02:58:27 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 06/10] soc: qcom: Add Qualcomm APSS minidump kernel driver Date: Wed, 31 Jan 2024 16:27:30 +0530 Message-ID: <20240131105734.13090-7-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 10vk0qaLTZTTV34kcvOIRfId3khjMqmW X-Proofpoint-GUID: 10vk0qaLTZTTV34kcvOIRfId3khjMqmW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603660383517693 X-GMAIL-MSGID: 1789603660383517693 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. Minidump mechanism provides the means for selecting region should be included in the ramdump. The solution supports extracting the Ramdump/Minidump produced either over USB or stored to an attached storage device. The core of Minidump feature is part of Qualcomm's boot firmware code. It initializes shared memory (SMEM), which is a part of RAM 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. 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 | 13 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_minidump.c | 606 ++++++++++++++++++++++ drivers/soc/qcom/qcom_minidump_internal.h | 10 + drivers/soc/qcom/smem.c | 20 + include/linux/soc/qcom/smem.h | 2 + include/soc/qcom/qcom_minidump.h | 18 + 7 files changed, 670 insertions(+) create mode 100644 drivers/soc/qcom/qcom_minidump.c diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 33584bbbfc0e..956336dae931 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -278,4 +278,17 @@ config QCOM_RPROC_MINIDUMP query predefined Minidump segments associated with the remote processor and check its validity and end up collecting the dump on remote processor crash during its recovery. + +config QCOM_MINIDUMP + tristate "QCOM APSS Minidump driver" + depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SMEM + help + This config enables Linux core infrastructure for Application + processor subsystem (APSS) Minidump collection, i.e., it enables + Linux client drivers to register their internal data structures + and debug messages as part of the APSS Minidump table and when + the SoC has crashed, these selective regions will be dumped + instead of the entire RAM dump. This saves a significant amount + of time and/or storage space. endmenu diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index fa685e5a12a6..c64082c33fc8 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -36,3 +36,4 @@ 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_RPROC_MINIDUMP) += qcom_rproc_minidump.o +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c new file mode 100644 index 000000000000..c0f76a51d0e8 --- /dev/null +++ b/drivers/soc/qcom/qcom_minidump.c @@ -0,0 +1,606 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qcom_minidump_internal.h" + +/** + * 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; +}; + +/** + * struct minidump_elfhdr - Minidump table elf header + * @ehdr: elf main header + * @shdr: Section header + * @phdr: Program header + * @elf_offset: Section offset in elf + * @strtable_idx: String table current index position + */ +struct minidump_elfhdr { + struct elfhdr *ehdr; + struct elf_shdr *shdr; + struct elf_phdr *phdr; + size_t elf_offset; + size_t strtable_idx; +}; + +/** + * struct minidump - Minidump driver data information + * @elf: Minidump elf header + * @dev: Minidump backend device + * @apss_data: APSS driver data + * @md_lock: Lock to protect access to APSS minidump table + */ +struct minidump { + struct minidump_elfhdr elf; + struct device *dev; + struct minidump_ss_data *apss_data; + struct mutex md_lock; +}; + +/* + * 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) + +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 minidump *md, 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_md_clear_elfheader(struct minidump *md, + 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(md, 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(*phdr)); + phdr->p_offset = phdr->p_offset - region->size; + } + memset(tmp_phdr, 0, sizeof(*tmp_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(*shdr)); + shdr->sh_offset -= region->size; + shdr->sh_name -= len; + } + + memset(tmp_shdr, 0, sizeof(*tmp_shdr)); + ehdr->e_shnum--; + md->elf.elf_offset -= region->size; + + return 0; +} + +static void qcom_md_update_elfheader(struct minidump *md, + 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 void qcom_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 qcom_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 int qcom_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 = qcom_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(*mdr)); + memset(&mdr[region_cnt - 1], 0, sizeof(*mdr)); + region_cnt--; + mdss_toc->region_count = cpu_to_le32(region_cnt); + + return 0; +} + +static int qcom_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 = qcom_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 >= MAX_NUM_ENTRIES) { + dev_err(md->dev, "maximum region limit %u reached\n", num_region); + return -ENOSPC; + } + + qcom_md_add_region(mdss_data, region); + + return 0; +} + +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. + */ +static int qcom_minidump_region_register(const struct qcom_minidump_region *region) +{ + struct minidump *md; + int ret; + + md = qcom_smem_minidump_ready(); + if (!md) + return -EPROBE_DEFER; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md->md_lock); + ret = qcom_md_region_register(md, region); + if (ret) + goto unlock; + + qcom_md_update_elfheader(md, region); +unlock: + mutex_unlock(&md->md_lock); + return ret; +} + +/** + * 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. + */ +static int qcom_minidump_region_unregister(const struct qcom_minidump_region *region) +{ + struct minidump *md; + int ret; + + md = qcom_smem_minidump_ready(); + if (!md) + return -EPROBE_DEFER; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md->md_lock); + ret = qcom_md_region_unregister(md, region); + if (ret) + goto unlock; + + ret = qcom_md_clear_elfheader(md, region); +unlock: + mutex_unlock(&md->md_lock); + return ret; +} + +static int qcom_md_add_elfheader(struct minidump *md) +{ + 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; + unsigned int banner_len; + char *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->elf.ehdr = devm_kzalloc(md->dev, elfh_size, GFP_KERNEL); + if (!md->elf.ehdr) + return -ENOMEM; + + ehdr = md->elf.ehdr; + /* Assign Section/Program headers offset */ + md->elf.shdr = shdr = (struct elf_shdr *)(ehdr + 1); + md->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->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->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, "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, "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->elf.ehdr; + elfregion.phys_addr = virt_to_phys(md->elf.ehdr); + elfregion.size = elfh_size; + + return qcom_md_region_register(md, &elfregion); +} + +static int qcom_apss_md_table_init(struct minidump *md, + struct minidump_subsystem *mdss_toc) +{ + struct minidump_ss_data *mdss_data; + + mdss_data = devm_kzalloc(md->dev, sizeof(*mdss_data), GFP_KERNEL); + if (!mdss_data) + return -ENOMEM; + + mdss_data->md_ss_toc = mdss_toc; + mdss_data->md_regions = devm_kcalloc(md->dev, MAX_NUM_ENTRIES, + sizeof(*mdss_data->md_regions), + 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 void qcom_apss_md_table_exit(struct minidump_ss_data *mdss_data) +{ + memset(mdss_data->md_ss_toc, cpu_to_le32(0), sizeof(*mdss_data->md_ss_toc)); +} + +static int qcom_apss_minidump_probe(struct platform_device *pdev) +{ + struct minidump_global_toc *mdgtoc; + struct minidump *md; + size_t size; + int ret; + + md = devm_kzalloc(&pdev->dev, sizeof(*md), GFP_KERNEL); + if (!md) + return -ENOMEM; + + md->dev = &pdev->dev; + mdgtoc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size); + if (IS_ERR(mdgtoc)) { + ret = PTR_ERR(mdgtoc); + return dev_err_probe(md->dev, ret, + "Couldn't find minidump smem item\n"); + } + + if (size < sizeof(*mdgtoc) || !mdgtoc->status) { + ret = -EINVAL; + return dev_err_probe(md->dev, ret, + "minidump table is not initialized\n"); + } + + mutex_init(&md->md_lock); + ret = qcom_apss_md_table_init(md, &mdgtoc->subsystems[MINIDUMP_APSS_DESC]); + if (ret) + return dev_err_probe(md->dev, ret, + "apss minidump initialization failed\n"); + + /* First entry would be ELF header */ + ret = qcom_md_add_elfheader(md); + if (ret) { + qcom_apss_md_table_exit(md->apss_data); + return dev_err_probe(md->dev, ret, "Failed to add elf header\n"); + } + + platform_set_drvdata(pdev, md); + + return ret; +} + +static void qcom_apss_minidump_remove(struct platform_device *pdev) +{ + struct minidump *md = platform_get_drvdata(pdev); + + qcom_apss_md_table_exit(md->apss_data); +} + +static const struct platform_device_id qcom_minidump_id_table[] = { + { .name = "qcom_minidump_smem" }, + {} +}; +MODULE_DEVICE_TABLE(platform, qcom_minidump_id_table); + +static struct platform_driver qcom_minidump_driver = { + .probe = qcom_apss_minidump_probe, + .remove_new = qcom_apss_minidump_remove, + .driver = { + .name = "qcom_minidump_smem", + }, + .id_table = qcom_minidump_id_table, +}; + +module_platform_driver(qcom_minidump_driver); + +MODULE_DESCRIPTION("Qualcomm APSS minidump driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h index 71709235b196..a2aebe5b690a 100644 --- a/drivers/soc/qcom/qcom_minidump_internal.h +++ b/drivers/soc/qcom/qcom_minidump_internal.h @@ -9,10 +9,20 @@ #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_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 * @name : Name of the region to be dumped diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7191fa0c087f..f7632624886f 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -270,6 +270,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 */ @@ -280,6 +281,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]; @@ -795,6 +797,15 @@ int qcom_smem_get_soc_id(u32 *id) } EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); +void *qcom_smem_minidump_ready(void) +{ + if (__smem && __smem->minidump) + return platform_get_drvdata(__smem->minidump); + else + return NULL; +} +EXPORT_SYMBOL_GPL(qcom_smem_minidump_ready); + static int qcom_smem_get_sbl_version(struct qcom_smem *smem) { struct smem_header *header; @@ -1173,11 +1184,20 @@ 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"); + smem->minidump = NULL; + } + return 0; } static void qcom_smem_remove(struct platform_device *pdev) { + platform_device_unregister(__smem->minidump); platform_device_unregister(__smem->socinfo); hwspin_lock_free(__smem->hwlock); diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h index a36a3b9d4929..08288360a55e 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -14,4 +14,6 @@ phys_addr_t qcom_smem_virt_to_phys(void *p); int qcom_smem_get_soc_id(u32 *id); +void *qcom_smem_minidump_ready(void); + #endif diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h index cd87caef919d..9fdf9e9d0af3 100644 --- a/include/soc/qcom/qcom_minidump.h +++ b/include/soc/qcom/qcom_minidump.h @@ -6,6 +6,24 @@ #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; +}; + struct rproc; struct rproc_dump_segment; From patchwork Wed Jan 31 10:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1808391dyb; Wed, 31 Jan 2024 03:04:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcRGkdnExi0rSEs98Ajz0fFnC6gYIKb5YoFqioOflUS9l7J66RZ65fmzeEv1XoGT8hgScW X-Received: by 2002:a17:906:abd4:b0:a31:8944:2cf6 with SMTP id kq20-20020a170906abd400b00a3189442cf6mr1303301ejb.8.1706699051866; Wed, 31 Jan 2024 03:04:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699051; cv=pass; d=google.com; s=arc-20160816; b=M7j2bLTT2sxoCVv1VD1zHR7k/dD9ahNXtxozGkxV063EAdvJU8ndZC1jyoGIUFVnXS tndIPvf/P3GNcr3MQIGEfZ3Ovq7ZYH1MXW0cWy/1484v6kCqORQnVTUU/t8akrtCBS8g CDBJRHVWEVTgkIj85XWtEI1UZUGK6TFb7ar22iV7cuMYkboyZSeoZwkoXrQ5MDgHzJDu HrDrD5Ho6sY7zALvfvdy6TkRZJKvFu9dsuw5ROadyW34oX+G1MaVMepIUOpEVxJH/DsG 6kzNsSaRvbXzSdcckFDrle9BMDLL5d+wkfGT38xKmA6+rD8+VgzL2WDCEEVHfCrUV7ZC or1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=erVnAJZx8ifcWPyB4Oavo8ehNHt/B3Y78dIRrq0/iQw=; fh=X1XLpYyu1MLB7hin2TB1XghxF7ZakEezSz/b7osS5RI=; b=knGKBNd5VgB2O9R84yWHtT2h119XKm6LlTKSRaOjUv8bJd00UDxanBX1y7imp4Qd9y 6hMWVzVQSUp+t8s/+lZx+q5PVy2NCg1Qsw8VvoaGQlyssqD4xZLxbOT4aMjz9Wn6PeMg ahKbi4NaqbGpN69E+koGb25THKJANZ85QYToUu75R9a0NeCBALhaAJvSihcBeL693oal 9nNjPGtLOUOafp4zOFkh852i0pkI0/xIar4T+GV2Ne7ET7jmsBoGNSXeST5MBJp/Borg R04lChrWfdlWnEhmNWqpRSCMuF1Se4ZbY3EJ3POmhyqFJ+83Z/b/RET6ljT4ZVlJvldP dvRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FW9ndo7h; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46293-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46293-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCXeDXrgjBB3HC+jjGaHplae0QBoxjqDgClhCRVGHtIP6B3/7+Mpfioi4i/y7hzX5+k4ffgqhYCpbHpFD7Q0HnqUY30xXQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u21-20020a170906409500b00a35fdfac2besi2005035ejj.1024.2024.01.31.03.04.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:04:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46293-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FW9ndo7h; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46293-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46293-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4E8281F2D4C3 for ; Wed, 31 Jan 2024 11:02:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A555F7D40F; Wed, 31 Jan 2024 10:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="FW9ndo7h" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84E9E7BB12; Wed, 31 Jan 2024 10:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698741; cv=none; b=nQSCfLap7RkGheehUjZ6QwdGkEM8ptUtJvwQMpWyIufsU6A/T+a3NVwCH55cKeXxKhjdbAyiNwgA/0TyeB6G/zGeDXsO/AAQEo5wqfEiQnhUlRxwuBM4Ax95f5RDPTsQhOKowPMUDfpDjPH9jLPc9cwFp2shbSMAWHjeZt+a/74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698741; c=relaxed/simple; bh=879o0stse/wM791U4PDWEqFXWnjbVgCb9rBx9CGi17U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hVhbfLU6fL0DmYFJqnTtTza1XiES7hPP1kj4nzpTW/BqCvYJnaXpRtaSqOekRjhnNPbHA850+HkI/TMfHPejJRE7998QX6ng85mJmTjy6Ol5WErNZnC4gW/H/AvQOw5B7TjlPg+K4LfhzJxWDmjdfWbUulR3O+gS/7XtempEedQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=FW9ndo7h; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V81I1i018844; Wed, 31 Jan 2024 10:58: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-transfer-encoding:content-type; s= qcppdkim1; bh=erVnAJZx8ifcWPyB4Oavo8ehNHt/B3Y78dIRrq0/iQw=; b=FW 9ndo7h8y9QmKgeHfGstf3crvoyctgVAn4HqkRpHHcRKU5plsj/eY5a3YHmKDOcV0 WdfpsT2re8LyazuDCKVkh5VAZ6lQ4XB7uhRAeMN9C2+BQf7rL1gVk5aJnQBuXYBz 9YCavnwFEifuCprE5+QWsxolXR3jhXkW0LPOfZ7d8bMMhERyXWDVDL4h1FElMAPK PEmBiG2N6vC/1zPohsOTncl6BJFwyNQDV767mthl0qR/NBB9xE+r8N9JqSC/EUaS tl3nnocxcjeadquFHe/YIv/FRoFpJmZWTv4RTOeM7Zxk9GhIX0mLONmAT7Cj0UBp 0NgVC4CURrEgRnC9qUqg== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyjas0d72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:39 +0000 (GMT) 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 40VAwcnE017839 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:38 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.1118.40; Wed, 31 Jan 2024 02:58:33 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 07/10] MAINTAINERS: Add entry for minidump related files Date: Wed, 31 Jan 2024 16:27:31 +0530 Message-ID: <20240131105734.13090-8-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: NrBa9WVzpsDVBuVWb9DUwPBKh4JE2BGq X-Proofpoint-ORIG-GUID: NrBa9WVzpsDVBuVWb9DUwPBKh4JE2BGq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxscore=0 mlxlogscore=859 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603665159942860 X-GMAIL-MSGID: 1789603665159942860 Add the entries into maintainer file for all the minidump related modules. Signed-off-by: Mukesh Ojha --- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c45587eb4c1d..a7eea6e64dce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18176,6 +18176,16 @@ 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_ramoops_minidump.c +F: drivers/soc/qcom/qcom_rproc_minidump.c + + QUALCOMM NAND CONTROLLER DRIVER M: Manivannan Sadhasivam L: linux-mtd@lists.infradead.org From patchwork Wed Jan 31 10:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1808461dyb; Wed, 31 Jan 2024 03:04:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFebJeHFRTPgmAJUSwQVhFNSF8gLriO0LSfZNQC0+P3lkvrFmlxILHEfNo7Im+gusKKNzOq X-Received: by 2002:a2e:3c0f:0:b0:2cf:36b:9abb with SMTP id j15-20020a2e3c0f000000b002cf036b9abbmr849186lja.44.1706699059436; Wed, 31 Jan 2024 03:04:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699059; cv=pass; d=google.com; s=arc-20160816; b=j41bqEb5z/PII/hdEIRi+btnQ2IFXlpsC2PPMjSH5vs0O364ASi2GWftWvtw1aNfee x1Vm8lT8NxSVihB/lZ1Oez/lQgeRNrEEi9MW9u1ThgODRVloEA5fveNEbSfecA9dyht9 R8YvlPpwvCnzFelgivIkZJKAYFqOASdLnEmzMKfU1vccOVvfcoATXjXxCBLAmfZfd1ki 2KK3gDuZKyGot1fM0b1m+tsqZSfrfcOdZzxS2w4twrDUbnQBzqEl7oIiVcE3EXHmq1Fu 6Z9XhH9XPEyW9IfoqNVQL/gEhPYJ6JZifMnWjj+u4M5vMgh8SPrbrt6q2KMYy3CUKe9k lgnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+9dhGTuTrvDtNIxH7q5czr/K4CZ1+Dif8CoPgq5i65c=; fh=JI7SOJhfJSa+szVUzi21cJWMGkG5mZqkpBd1XiAU0/w=; b=F3TeYiBqzscvIN1mb5vVeHA4VYApUQICpwf51dwUEJDplFvxyTvPQjuzZiLB34s3f8 4u0Xiez2mnJIQHZ/jqN2s2n+cY5M+n1HYZDiWHb1ye//S9rC/xtQzxthu0nbULQahmCJ cjkXmTR1nk+FZTVC2NbrZ7IzuD0FuY7uQuj08EZJ9gsuNOqmJxewi7xLykRNMJNfBGNs uaE5kEuE585Jt7nuKKwWq2BetLV8rSUX0ecxM7PpOZ6S7UBZH5TVNJraWqJ0+S9JNmHY DzXJ1EVOfIF0PxzKn+r/2zpYZW0rC/rrUklXjZXVqIaflJGJ85PRpCkowcmkVtoaBFVV iGMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SEoXyIMM; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46294-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46294-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCVewBgJfUBuys7mcvPWYy3V6DpVDCsXxBUKX2iQCptDD/VLLiIs7EG5tikaymtegh0ji2CvN2ZO2cWUvz7Qgd5GWGPSvw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cs5-20020a0564020c4500b0055c5ca0f656si5621910edb.503.2024.01.31.03.04.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:04:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46294-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SEoXyIMM; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46294-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46294-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CFB621F2E5AD for ; Wed, 31 Jan 2024 11:02:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AAB877625; Wed, 31 Jan 2024 10:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="SEoXyIMM" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B05FE7D3FF; Wed, 31 Jan 2024 10:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698745; cv=none; b=T+pFd1r1AVBPBNoLtWth7OHnN9VCHoqCKowdbDH/NKMaMnWNR6zSuPQlOFrZMOvV1jm01v1bljMR1oVBqvUVLvXj0EhlEnEe4/ZMat0YbK4d3FULSjw0YrzSFILaXrGlZEe0IrS06StdaPHmQ9TbiX/+OAJk7NjT8F+47JGJ81U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698745; c=relaxed/simple; bh=1ZxZNZCM1dcA+Ma7AiD7q3Mt0qj7DACwdROPA6/w67o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bTxR4MMrs7pMa6Hi5dkCpW+56UuuJ6GNvo8/OOIuOuSGHGBaUF03sBEVIjMgaYGHoWjdBYQP7CwwYsfUzdBcD2fhsixImmV03I8oe4c8n2qZgImgV6t1cu6zoxUuD5InKeJLIZNbHPWeDj7K1+cAnMp/BA3LcFZFYzruqAQXDcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=SEoXyIMM; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V77Tov002033; Wed, 31 Jan 2024 10:58: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-transfer-encoding:content-type; s= qcppdkim1; bh=+9dhGTuTrvDtNIxH7q5czr/K4CZ1+Dif8CoPgq5i65c=; b=SE oXyIMMbUxb5qWqFPcA9gQlATTNL3e4cgkzexDMk28FBdFLkDYemfFoSQnvk8URXl ZQEvkTlFpLbMd27uQdPnCRyCDQN0w/FnFFzsvotEuSc7z2ikClQXD4XigDqMrXe2 RNhO8XfxXAcHK9dNumqWJhqvX6QVS927tr0WYl+WeCFjYced6VrPjslautkEjEGm vhGLSZqFK4S7CBXAbO0gAF/6NL3xdL59PVCuaq15wFangyTeaNyl1uziwM5L6WAF dMWv6rWBbQlV7R5uCpzsXtZFCX0p4/xLDYrFNz9Bi4I3JOWjRHTR8WLfm0sU25ml riuAJKHT/eo8Vql42QJg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vy4rqabtk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:44 +0000 (GMT) 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 40VAwh35017924 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58: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.1118.40; Wed, 31 Jan 2024 02:58:38 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 08/10] pstore/ram: Add dynamic ramoops region support through commandline Date: Wed, 31 Jan 2024 16:27:32 +0530 Message-ID: <20240131105734.13090-9-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: mEiRlN5fdGyLSeDSi-TtI4lOqjhZSZeH X-Proofpoint-GUID: mEiRlN5fdGyLSeDSi-TtI4lOqjhZSZeH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 clxscore=1015 bulkscore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603673228985643 X-GMAIL-MSGID: 1789603673228985643 The reserved memory region for ramoops is assumed to be at a fixed and known location when read from the devicetree. This may not be required for something like Qualcomm's minidump which is interested in knowing addresses of ramoops region but it does not put hard requirement of address being fixed as most of its SoC does not support warm reset and does not use pstorefs at all instead it has firmware way of collecting ramoops region if it gets to know the address and register it with apss minidump table which is sitting in shared memory region in DDR and firmware will have access to these table during reset and collects it on crash of SoC. So, add the support of reserving ramoops region to be dynamically allocated early during boot if it is request through command line via 'dyn_ramoops_size=' and fill up reserved resource structure and export the structure, so that it can be read by ramoops driver. Signed-off-by: Mukesh Ojha --- Documentation/admin-guide/ramoops.rst | 23 +++++++++- fs/pstore/Kconfig | 15 ++++++ fs/pstore/ram.c | 66 +++++++++++++++++++++++++-- include/linux/pstore_ram.h | 5 ++ init/main.c | 3 ++ 5 files changed, 108 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/ramoops.rst b/Documentation/admin-guide/ramoops.rst index e9f85142182d..6de61002f9e9 100644 --- a/Documentation/admin-guide/ramoops.rst +++ b/Documentation/admin-guide/ramoops.rst @@ -33,6 +33,13 @@ memory are implementation defined, and won't work on many ARMs such as omaps. Setting ``mem_type=2`` attempts to treat the memory region as normal memory, which enables full cache on it. This can improve the performance. +Ramoops supports its memory to be allocated dynamically during early boot +for plaforms that do not have support for warm boot i.e., no assurance +that Ram content will be preserved across boot and for these platforms +giving static Ramoops memory is not necessary as it has separate backend +mechanism to retrieve ramoops content on system failure. More about +how to enable Dynamic ramoops in ``Setting the parameters`` A.b section. + The memory area is divided into ``record_size`` chunks (also rounded down to power of two) and each kmesg dump writes a ``record_size`` chunk of information. @@ -59,7 +66,7 @@ Setting the parameters Setting the ramoops parameters can be done in several different manners: - A. Use the module parameters (which have the names of the variables described + A.a Use the module parameters (which have the names of the variables described as before). For quick debugging, you can also reserve parts of memory during boot and then use the reserved memory for ramoops. For example, assuming a machine with > 128 MB of memory, the following kernel command line will tell @@ -68,6 +75,20 @@ Setting the ramoops parameters can be done in several different manners: mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1 + A.b Ramoops memory can be also be dynamically reserved by Kernel and in such + scenario ``mem_address`` i.e., Ramoops base address can be anywhere in the RAM + instead of being fixed and predefined. A separate command line option + ``dyn_ramoops_size=`` and kernel config CONFIG_PSTORE_DYNAMIC_RAMOOPS + are provided to facilitate Dynamic Ramoops memory reservation during early boot. + The command line option and the config should only be used in the presence of + separate backend which knows how to recover Dynamic Ramoops region otherwise + regular ramoops functionality will be impacted. + ``mem_size`` should not be used if Dynamic Ramoops support is requested and if + both are given ``mem_size`` value is overwritten with ``dyn_ramoops_size`` value + i.e., Dynamic Ramoops takes precedence:: + + dyn_ramoops_size=2M ramoops.console_size=2097152 + B. Use Device Tree bindings, as described in ``Documentation/devicetree/bindings/reserved-memory/ramoops.yaml``. For example:: diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 3acc38600cd1..b8bdbd2f0e73 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -81,6 +81,21 @@ config PSTORE_RAM For more information, see Documentation/admin-guide/ramoops.rst. +config PSTORE_DYNAMIC_RAMOOPS + bool "Reserve ramoops region dynamically" + select PSTORE_RAM + help + This enables the dynamic reservation of ramoops region for a special case + where there is no need to access the logs from pstorefs on next boot; + instead there is separate backend mechanism like minidump present which has + awareness about the dynamic ramoops region and can recover the logs. This is + enabled via command line parameter dyn_ramoops_size= and should not be + used in absence of separate backend which knows how to recover this dynamic + region. + + Note whenever this config is selected ramoops driver will be built statically + into kernel. + config PSTORE_ZONE tristate depends on PSTORE diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 88b34fdbf759..1faf0835700b 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "internal.h" @@ -103,6 +104,59 @@ struct ramoops_context { }; static struct platform_device *dummy; +static struct resource dyn_ramoops_res = { + .name = "ramoops", + .start = 0, + .end = 0, + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_NONE, +}; +static int dyn_ramoops_size; + +#ifdef CONFIG_PSTORE_DYNAMIC_RAMOOPS +static int __init parse_dyn_ramoops_size(char *p) +{ + char *tmp; + + dyn_ramoops_size = memparse(p, &tmp); + if (p == tmp) { + pr_err("ramoops: memory size expected\n"); + dyn_ramoops_size = 0; + return -EINVAL; + } + + return 0; +} +early_param("dyn_ramoops_size", parse_dyn_ramoops_size); + +/* + * setup_dynamic_ramoops() - Reserve memory for dynamic ramoops + * + * Enables dynamic reserve memory support for ramoops through + * command line. + */ +void __init setup_dynamic_ramoops(void) +{ + unsigned long long ramoops_base; + unsigned long long ramoops_size; + + if (!dyn_ramoops_size) + return; + + ramoops_base = memblock_phys_alloc_range(dyn_ramoops_size, SMP_CACHE_BYTES, + 0, MEMBLOCK_ALLOC_NOLEAKTRACE); + if (!ramoops_base) { + pr_err("cannot allocate ramoops dynamic memory (size:0x%llx).\n", + ramoops_size); + dyn_ramoops_size = 0; + return; + } + + dyn_ramoops_res.start = ramoops_base; + dyn_ramoops_res.end = ramoops_base + dyn_ramoops_size - 1; + insert_resource(&iomem_resource, &dyn_ramoops_res); +} +#endif static int ramoops_pstore_open(struct pstore_info *psi) { @@ -915,13 +969,19 @@ static void __init ramoops_register_dummy(void) /* * Prepare a dummy platform data structure to carry the module - * parameters. If mem_size isn't set, then there are no module - * parameters, and we can skip this. + * parameters. + * + * dyn_ramoops_size takes precedence over mem_size if it is + * enabled and valid. */ - if (!mem_size) + if (!dyn_ramoops_size && !mem_size) return; pr_info("using module parameters\n"); + if (dyn_ramoops_size) { + mem_size = dyn_ramoops_size; + mem_address = dyn_ramoops_res.start; + } memset(&pdata, 0, sizeof(pdata)); pdata.mem_size = mem_size; diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index 9d65ff94e216..1efff7a38333 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -39,4 +39,9 @@ struct ramoops_platform_data { struct persistent_ram_ecc_info ecc_info; }; +#ifdef CONFIG_PSTORE_DYNAMIC_RAMOOPS +void __init setup_dynamic_ramoops(void); +#else +static inline void __init setup_dynamic_ramoops(void) {} +#endif #endif diff --git a/init/main.c b/init/main.c index ef3ce41b8fc5..3d74241bcb2b 100644 --- a/init/main.c +++ b/init/main.c @@ -99,6 +99,8 @@ #include #include #include +#include +#include #include #include @@ -890,6 +892,7 @@ void start_kernel(void) pr_notice("%s", linux_banner); early_security_init(); setup_arch(&command_line); + setup_dynamic_ramoops(); setup_boot_config(); setup_command_line(command_line); setup_nr_cpu_ids(); From patchwork Wed Jan 31 10:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1808537dyb; Wed, 31 Jan 2024 03:04:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcijDoM7WrjDRlxPCuGoYr+4S1YwlLWFGSyTJoPS6w8S+LNYYdazHFDXJ/zQrd7KEYfxpj X-Received: by 2002:a2e:aa27:0:b0:2d0:61a4:6c56 with SMTP id bf39-20020a2eaa27000000b002d061a46c56mr899877ljb.30.1706699066747; Wed, 31 Jan 2024 03:04:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699066; cv=pass; d=google.com; s=arc-20160816; b=dCOkdnuTwhpMK6dIT4874S2xKgzY+Ryt2cETAO6bUnqfJFIv9pROIg8C/5kebU73AT WCmNMwVzCM3xcQNU89EF6NBnZlhAHWCFpTGpt4wzxmTayl6OEv6P5ivuLvLYRdSGaQ8y EVcNPjCXf6lGg3wHxCxoakWs7ALIG/BW7Ppxhb1HeCkEf9M315ph5bQPADGa3yIhe2Hc 9CHdqNSY6sm2C3Y93U4SBZfdFmwMGrqgeQ+1wThFTyf5qXRlve+BeAAmiqHwH/n8YcJ4 5lw2H8J4Z63yKggjmDAiSkGMCKhZA7u0wQJSJ+I7i6fFWJ4OU5cV4dlaMG4YB0d9MRUx NtqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eu4+fj6D3iVrbZw4NhJ6j+Qbrx8bAr3vCJR8zRmV4mQ=; fh=WDr2QHv4BcBosSf1vwKc0ywb0lj6wmLM6zcF4Wn6T+c=; b=UsNMsNqY1JhVfjnJWc0LN3UbU0EgJamXKcfh7EBKTZ5fgXlfy/SyKnOl+ACfuMSq0T dytE4CPq6iZ3sIPUV1vzXb1QgDoEvRZjXiFDRK7vJaERiw5lRGg/bCDYbgKT5Xpzutlz agoCYsnYZymFzKg4C0GCE7pRvbRIZE1HifdXM3LXuq6Dj5cculPzEtFNiK2NZg4sCcMn jvU+BwT93BpnWTGC9iQHErfj5Xe5cI0C3xgty474JvTNcK28nQgGherOAmgb1lEfgjTA OhusOJQ8jC7c6gi1tlfYz9H5vzA6PuJzDFsLLUpsiRMo0IRLvejQbg/PZ7rlhM/gPQtK DOTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N+yLsmNr; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46295-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46295-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCXRPOa7GGNpLGjDRZhZwuzzOimx8l6wjc6GG9GB/WZeHNc2/0K7KXr7SQW7TIsJbiCR+j3WIRuiT02y1P9ZZEwcX/odTA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lu10-20020a170906faca00b00a36009ee6d7si1984003ejb.1012.2024.01.31.03.04.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:04:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46295-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N+yLsmNr; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46295-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46295-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2B8FD1F2EA20 for ; Wed, 31 Jan 2024 11:02:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 252C47F473; Wed, 31 Jan 2024 10:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="N+yLsmNr" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0740D7F462; Wed, 31 Jan 2024 10:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698750; cv=none; b=T13bqrUnpXbJ1rafCJhx4O2q2/GjBqxUS7qOLtrgWNW/RHnH/hUn6Qm5lP2MzGvSgpJfKg6BbwEfajZbvvrzHqZmPLzY/rP9NxaTLKGkupzheneqeVbw+AEiLbjJg+Ap2Cy3RI0yT8djX8xbZ9j0cE7AxZH4Ud2F5/iNav9M0gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698750; c=relaxed/simple; bh=2aMh3wOVlqpU6igYMIpqzplWbecfTNjZwrEdrt9ImGI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tGAlVjkJp8NAL/8/Sm8mi+82VWryesgkLsBNN893nuz2fKYxJ2+HIQCjjx2gmNX/JxOymwzsse8YIhPGXWQ8vRTqA8gNSVjdZ7PzPGNADqS3Im8xvNgEwkOD8tucTxmadWGal150+zVlpdlabRDSJ5u5x/7Phy2gXxqv7NlYf3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=N+yLsmNr; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40VAbpbT022114; Wed, 31 Jan 2024 10:58:50 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-transfer-encoding:content-type; s= qcppdkim1; bh=eu4+fj6D3iVrbZw4NhJ6j+Qbrx8bAr3vCJR8zRmV4mQ=; b=N+ yLsmNrxNt8fb/9H9RhwErKXTDyyu061zPMvHHuJGTSzfC7U5lA+53xXjQIKSgkG8 KdeJjwNvgRxAkvOSPHiLEKzKIz0ABH1wsudj2f90gfCnjgR+la8pXMVLenGCvhUX xQstn7ewkbGMzTnuFEbq2zutHjLNi52oIVihbEw5tma5JSdXScahVVmej9i6LQDC YhsnMKQiOmqCBxrs23MEuAhvWC4ajRu1ZU/6ukT89LhOBq5p5r0huftj5WvYkrWw J6/kRtK85yG1s46LVa2AKjuly00+pxq+y/VcG+tJ4hQP/Rz40iF/iBEC1KF/soI1 /olvrNVBdQ4vpDm6WCYA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyfc8rxpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:50 +0000 (GMT) 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 40VAwnTA017975 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58: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.1118.40; Wed, 31 Jan 2024 02:58:44 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 09/10] pstore/ram: Add ramoops information notifier support Date: Wed, 31 Jan 2024 16:27:33 +0530 Message-ID: <20240131105734.13090-10-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: eGNp1POdviZb8zui7yY2ps0rHylZ9jUG X-Proofpoint-ORIG-GUID: eGNp1POdviZb8zui7yY2ps0rHylZ9jUG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603680492244241 X-GMAIL-MSGID: 1789603680492244241 Client like minidump is interested in knowing ramoops individual zone addresses and their size so that it could register them with its table. Let's introduce a info notifier in ramoops which gets called when ramoops driver probes successfully and it passes the ramoops region information to the passed callback by the client and If the call for ramoops ready register comes after ramoops probe than call the callback directly. Signed-off-by: Mukesh Ojha --- fs/pstore/ram.c | 114 +++++++++++++++++++++++++++++++++++++ include/linux/pstore_ram.h | 15 +++++ 2 files changed, 129 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 1faf0835700b..bd94c11e43ff 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "internal.h" #include "ram_internal.h" @@ -101,6 +103,19 @@ struct ramoops_context { unsigned int ftrace_read_cnt; unsigned int pmsg_read_cnt; struct pstore_info pstore; + struct blocking_notifier_head ramoops_notifiers; + bool ramoops_ready; + /* + * Lock to serialize access to ramoops_ready and to not + * miss any ongoing notifier registration while ramoops + * probe is in progress. + */ + struct mutex lock; +}; + +struct ramoops_backend { + struct notifier_block nb; + int (*fn)(const char *name, int id, void *vaddr, phys_addr_t paddr, size_t size); }; static struct platform_device *dummy; @@ -501,6 +516,8 @@ static struct ramoops_context oops_cxt = { .write_user = ramoops_pstore_write_user, .erase = ramoops_pstore_erase, }, + .ramoops_notifiers = BLOCKING_NOTIFIER_INIT(oops_cxt.ramoops_notifiers), + .lock = __MUTEX_INITIALIZER(oops_cxt.lock), }; static void ramoops_free_przs(struct ramoops_context *cxt) @@ -666,6 +683,98 @@ static int ramoops_init_prz(const char *name, return 0; } +static int __ramoops_info_notifier(struct ramoops_context *cxt, int (*fn)(const char *, + int, void *, phys_addr_t, size_t)) +{ + struct persistent_ram_zone *prz; + int ret; + int i; + + for (i = 0; i < cxt->max_dump_cnt; i++) { + prz = cxt->dprzs[i]; + ret = fn("dmesg", i, prz->vaddr, prz->paddr, prz->size); + if (ret < 0) + goto err; + } + + if (cxt->console_size) { + prz = cxt->cprz; + ret = fn("console", 0, prz->vaddr, prz->paddr, prz->size); + if (ret < 0) + goto err; + } + + for (i = 0; i < cxt->max_ftrace_cnt; i++) { + prz = cxt->fprzs[i]; + ret = fn("ftrace", i, prz->vaddr, prz->paddr, prz->size); + if (ret < 0) + goto err; + } + + if (cxt->pmsg_size) { + prz = cxt->mprz; + ret = fn("pmsg", 0, prz->vaddr, prz->paddr, prz->size); + if (ret < 0) + goto err; + } + +err: + return ret; +} + +static int ramoops_info_notifier(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct ramoops_backend *b_info = container_of(nb, struct ramoops_backend, nb); + struct ramoops_context *cxt = data; + + return __ramoops_info_notifier(cxt, b_info->fn); +} + +void *register_ramoops_info_notifier(int (*fn)(const char *, int, + void *, phys_addr_t, size_t)) +{ + struct ramoops_context *cxt = &oops_cxt; + struct ramoops_backend *b_info; + + mutex_lock(&cxt->lock); + /* + * There is no need to register callback if ramoops probe + * is already done instead, call the callback directly + */ + if (cxt->ramoops_ready) { + mutex_unlock(&cxt->lock); + __ramoops_info_notifier(cxt, fn); + return NULL; + } + + b_info = kzalloc(sizeof(*b_info), GFP_KERNEL); + if (!b_info) { + b_info = ERR_PTR(-ENOMEM); + goto out; + } + + b_info->fn = fn; + b_info->nb.notifier_call = ramoops_info_notifier; + blocking_notifier_chain_register(&cxt->ramoops_notifiers, &b_info->nb); + +out: + mutex_unlock(&cxt->lock); + return b_info; +} +EXPORT_SYMBOL_GPL(register_ramoops_info_notifier); + +void unregister_ramoops_info_notifier(void *b_info) +{ + struct ramoops_context *cxt = &oops_cxt; + struct ramoops_backend *tmp = b_info; + + mutex_lock(&cxt->lock); + blocking_notifier_chain_unregister(&cxt->ramoops_notifiers, &tmp->nb); + mutex_unlock(&cxt->lock); +} +EXPORT_SYMBOL_GPL(unregister_ramoops_info_notifier); + /* Read a u32 from a dt property and make sure it's safe for an int. */ static int ramoops_parse_dt_u32(struct platform_device *pdev, const char *propname, @@ -915,6 +1024,11 @@ static int ramoops_probe(struct platform_device *pdev) ramoops_pmsg_size = pdata->pmsg_size; ramoops_ftrace_size = pdata->ftrace_size; + mutex_lock(&cxt->lock); + cxt->ramoops_ready = true; + mutex_unlock(&cxt->lock); + blocking_notifier_call_chain(&cxt->ramoops_notifiers, 0, cxt); + pr_info("using 0x%lx@0x%llx, ecc: %d\n", cxt->size, (unsigned long long)cxt->phys_addr, cxt->ecc_info.ecc_size); diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index 1efff7a38333..7e27cfc09243 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -39,6 +39,21 @@ struct ramoops_platform_data { struct persistent_ram_ecc_info ecc_info; }; +#if IS_ENABLED(CONFIG_PSTORE_RAM) +void *register_ramoops_info_notifier(int (*fn)(const char *name, int id, + void *vaddr, phys_addr_t paddr, + size_t size)); +void unregister_ramoops_info_notifier(void *nb_cookie); +#else +static inline void *register_ramoops_info_notifier(int (*fn)(const char *name, int id, + void *vaddr, phys_addr_t paddr, + size_t size)) +{ + return NULL; +} +static inline void unregister_ramoops_info_notifier(void *nb_cookie) { } +#endif + #ifdef CONFIG_PSTORE_DYNAMIC_RAMOOPS void __init setup_dynamic_ramoops(void); #else From patchwork Wed Jan 31 10:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 194677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1808712dyb; Wed, 31 Jan 2024 03:04:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IECFIdRItbcXdA5Jt13yjGwvKJucIvFogmjb73w7dhCu6Az5qf62FVl/S6erKLM1rOaKIVX X-Received: by 2002:a17:906:1d42:b0:a35:15ea:3cc0 with SMTP id o2-20020a1709061d4200b00a3515ea3cc0mr3571473ejh.26.1706699080483; Wed, 31 Jan 2024 03:04:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699080; cv=pass; d=google.com; s=arc-20160816; b=0hYL85kzdayJlrWHZO0pnXaaPNNwK6CZmeDUSw3pNW6wUvocd6fGxNMCaDCT+XMWCU FqGuXkbzrtthWsETz0/WsoV9Z/ncGmvjkXJ4LpsUmVG2AXrKaXPcL4XAaa48AJoZSXlv yavotw4ZRIH6sstaU5YgkNmGsbJwK5yjdPhURi/lL7KfcPCmMY2RehKin1iIx9CbTgG4 1gZ3QQTJYjIUYm0Y7XzQKAChYRrbqob3wW3dpdGsxlOD5xn/UGaiH88DtYwwGHOQDsSR Luy049WHQVcZWlconb1sWHLpJbiM7YxRq/fcO2mqYHKxJtcm3hirWdV+QafvAFZ8Ku4P gSYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OdVX0vbjRwNHZr0+EmbFNFjxgdY3hDawnsBgwICg6LI=; fh=nIGjACx3KnxrCjB6ZYZx3e1+5KOQ8IDKK/RzsJJcZlY=; b=wFxnuzyqu/yYLR4NgD26RpDqs/6O/cj0K2mrvt2wm0RkEbFy2bQWRzzGG9s5JYo2fR vydBHWzYTw5PPy4FRGSeQckqz4TTxsIrSdYgEnhzNfpTUSCoLp4z/06KfRfWqsRRbK10 jyQxq05n30FmYP8JmiVRTIrgl82GkjkTyqZVZHF33PsZRQbWbW0hRyVP0CnlXNy/1+R5 2e/LAq5N/eVtR7Eb3+xWpQhOapzZH8XWFhcH756iiUeHNQ8rthQL2YAictU7Fh9tASQz +/jWfEtxAKcCcqBp14obGb2IoLAAplN+/HE5FuK/w8C0hyy6A7c0U6ffdts/oGRE+lt4 lpfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=S1LkaQXJ; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46296-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46296-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCW4Eue6KIwq4GbDF97AoGyqQgFvtPDN7VvOdnoi+Bv3GXzJla+CeYnkWUibS8abJQCe9mF14tkRGQ8Zenhdnhx+Hwxs4A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j6-20020a17090643c600b00a363829537esi1284168ejn.649.2024.01.31.03.04.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46296-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=S1LkaQXJ; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-46296-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46296-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F1E661F2E4DB for ; Wed, 31 Jan 2024 11:03:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ADDA80BF1; Wed, 31 Jan 2024 10:59:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="S1LkaQXJ" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68BC87F47D; Wed, 31 Jan 2024 10:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698755; cv=none; b=XW9ItN9ZAbIPo324KGrT0I7Vz7LVZmJ2I2WxOSMUKetUU46A3R9KgA+4UPjt4ufGoPigl8pD8jMiWC3x3BhlnPsSu9KHUFMIEyPqoXY1TPrwpkoOqnKOUlWBPuEh8D5yMhXpIy1Ip2unX1QezOYyMIFlb3wm0Wc88BOUX1Cc0Tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698755; c=relaxed/simple; bh=F8ej+RfKy5uRlP3BtIE6c20cYRN6falVBUA+PQCrR74=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GjH894GUXW0ow52wSSoys7/PH/hggRbl9a36JwE4ZUC75uhXyk6qZsMKX7gq6T8laCgZENMvii98YXxqCHmmvtKEd5602bRBC7Y4/YwlSIsEHcqtNv0fAmJ8H96/ccwg88cz+j2ysFXYTdqoSuLeWF8drPZfupZWZZ1Z3Gr0HS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=S1LkaQXJ; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40VAHrd8012122; Wed, 31 Jan 2024 10:58:55 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-transfer-encoding:content-type; s= qcppdkim1; bh=OdVX0vbjRwNHZr0+EmbFNFjxgdY3hDawnsBgwICg6LI=; b=S1 LkaQXJgNdTCZlvAu8gSxrB5vv45OZKyZw6++LZT8JPBbekoxUqpNRHO76eGpjT9M RdANaGmT6yt0nd+rsLElYecbE09BZ9coVa+zKTsedar8lgbniAajcuSiR+bB5KgJ dJxlPgZK2Nvx1MRbRmEtE+6c9McADKfa1PBob6C4o9S7M7hYHvkafHC/F707eCPR JGTkANboDW5kXgaqj26hA8tSLr7XqF24hytQ53HHrNKCurWORgB22d5sUeHKtwrC HkIEzViSea4+ERFWzDme0aLw7RnSRTHMOe+Ljk8Nbo/5/thBQLPF1Y/odVswukgb H4W0Mztru2Y/olx9tw5A== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vygp7gs3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:55 +0000 (GMT) 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 40VAws2x017997 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 10:58:54 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.1118.40; Wed, 31 Jan 2024 02:58:49 -0800 From: Mukesh Ojha To: , , , , , , , , , , , , , , , CC: , , Mukesh Ojha Subject: [PATCH v8 10/10] soc: qcom: register ramoops region with APSS minidump Date: Wed, 31 Jan 2024 16:27:34 +0530 Message-ID: <20240131105734.13090-11-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 In-Reply-To: <20240131105734.13090-1-quic_mojha@quicinc.com> References: <20240131105734.13090-1-quic_mojha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: hPabgsbsaFj4Yv1f4zb9b2cxjr3qwjDP X-Proofpoint-GUID: hPabgsbsaFj4Yv1f4zb9b2cxjr3qwjDP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_06,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxscore=0 suspectscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789603694818405330 X-GMAIL-MSGID: 1789603694818405330 Register ramoops region with APSS minidump via ramoops info notifier so that these region gets captured on system crash. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/qcom_minidump.c | 84 ++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c index c0f76a51d0e8..7ca43d938b13 100644 --- a/drivers/soc/qcom/qcom_minidump.c +++ b/drivers/soc/qcom/qcom_minidump.c @@ -18,8 +18,10 @@ #include #include #include +#include #include #include +#include #include #include "qcom_minidump_internal.h" @@ -56,12 +58,22 @@ struct minidump_elfhdr { * @dev: Minidump backend device * @apss_data: APSS driver data * @md_lock: Lock to protect access to APSS minidump table + * @work: Minidump work for any required execution in process context. + * @nb_cookie: Save the cookie, will be used for unregistering the callback. */ struct minidump { struct minidump_elfhdr elf; struct device *dev; struct minidump_ss_data *apss_data; struct mutex md_lock; + struct work_struct work; + void *nb_cookie; +}; + +static LIST_HEAD(apss_md_rlist); +struct md_region_list { + struct qcom_minidump_region md_region; + struct list_head list; }; /* @@ -530,6 +542,58 @@ static int qcom_apss_md_table_init(struct minidump *md, return 0; } +static int register_ramoops_region(const char *name, int id, void *vaddr, + phys_addr_t paddr, size_t size) +{ + struct qcom_minidump_region *md_region; + struct md_region_list *mdr_list; + int ret; + + mdr_list = kzalloc(sizeof(*mdr_list), GFP_KERNEL); + if (!mdr_list) + return -ENOMEM; + + md_region = &mdr_list->md_region; + scnprintf(md_region->name, sizeof(md_region->name), "K%s%d", name, id); + md_region->virt_addr = vaddr; + md_region->phys_addr = paddr; + md_region->size = size; + ret = qcom_minidump_region_register(md_region); + if (ret < 0) { + pr_err("failed to register region in minidump: err: %d\n", ret); + return ret; + } + + list_add(&mdr_list->list, &apss_md_rlist); + + return 0; +} + +static void register_ramoops_minidump_cb(struct work_struct *work) +{ + struct minidump *md = container_of(work, struct minidump, work); + + md->nb_cookie = register_ramoops_info_notifier(register_ramoops_region); + if (IS_ERR_OR_NULL(md->nb_cookie)) { + pr_err("Fail to register ramoops info notifier\n"); + md->nb_cookie = NULL; + } +} + +static void qcom_ramoops_minidump_unregister(void) +{ + struct md_region_list *mdr_list; + struct md_region_list *tmp; + + list_for_each_entry_safe(mdr_list, tmp, &apss_md_rlist, list) { + struct qcom_minidump_region *region; + + region = &mdr_list->md_region; + qcom_minidump_region_unregister(region); + list_del(&mdr_list->list); + } +} + static void qcom_apss_md_table_exit(struct minidump_ss_data *mdss_data) { memset(mdss_data->md_ss_toc, cpu_to_le32(0), sizeof(*mdss_data->md_ss_toc)); @@ -575,6 +639,22 @@ static int qcom_apss_minidump_probe(struct platform_device *pdev) platform_set_drvdata(pdev, md); + /* + * Use separate context for registering ramoops region via workqueue + * as minidump probe can get called in same context of platform device + * register call from smem driver and further call to qcom_smem_minidump_ready() + * can return -EPROBE_DEFER as __smem->minidump is not yet initialized because + * of same context and it can only initialized after return from probe. + * + * qcom_apss_minidump_probe() + * register_ramoops_minidump_cb() + * register_ramoops_region() + * qcom_minidump_region_register() + * qcom_smem_minidump_ready() + */ + INIT_WORK(&md->work, register_ramoops_minidump_cb); + schedule_work(&md->work); + return ret; } @@ -582,6 +662,10 @@ static void qcom_apss_minidump_remove(struct platform_device *pdev) { struct minidump *md = platform_get_drvdata(pdev); + flush_work(&md->work); + qcom_ramoops_minidump_unregister(); + if (md->nb_cookie) + unregister_ramoops_info_notifier(md->nb_cookie); qcom_apss_md_table_exit(md->apss_data); }