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); }