Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2919392rdh; Mon, 27 Nov 2023 02:11:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn3hTc+3bMIIK/uHC0jkNpFqJpfqenhQZPWs/Vg4IBdcHXFvyquTMs7W1YvRn1GRkCQ+ME X-Received: by 2002:a05:6a00:2e94:b0:6cb:ce35:2b1d with SMTP id fd20-20020a056a002e9400b006cbce352b1dmr11290316pfb.16.1701079910025; Mon, 27 Nov 2023 02:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701079910; cv=none; d=google.com; s=arc-20160816; b=W4oAeOh9+HdCXvwxjh0B1iVfFXhQJ8Fx5MkmirkTKuOf7JsnCNg8p++r3ROYjFZxJ0 RHonYvnqmH3BEczRlPNg7RWcA+036hTncvezAG39iXNKpLDdPfF4yBnVSRcxCoEXne6Z c3d/mSU97Z8w2NZ3M39LxeCfpOrI7m7lO7Bn+LKx6562m/uQtoyLyxii57oJv6q3QOMO paPLBUpQpw4CmpL8xQNe38yN8fslqWvcvdSaKtYysOiNDKgmQVLKcULCAjBCx2BH7MfA tExDL5zk0Jbc6bF6IWKUN5zTtVcpyHoo/RWvdjiU3Fza9IAqGbrGs1jsnYHf1KwYpjO8 DCvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EY/c6/Ci98EonGSNUz6fVfm6jLBxiwZHNUrcbJIhhUc=; fh=XpAMXvmvT4gVllgr3/uleKeXpNpWSGVjR4vqzW5TkJ4=; b=y3WnGYTiw20UC40akODIqQGC1cOATIaCUxDTsZwi9Z5WRWgt355OCPpfSh0R5/VOzZ cuTWXc/yAURx+4ZHfaPpqZKNm/BF9eSIR70oGkwpDwgoa+M2jnEuMY0WzaD2OA6BxD2Z mFdOqCGCJAJRxFMjKXYFpf/ZVUEkhHVIirVkdjY5XaMmsqwgAr8k/ajir9U8WrNx/Ale SxNaejtZ7hOKeetaYU0xC9Hwb/a22IAQ/bdlPznLjPOKzBTDsr761NO7ScdFk2TAGlMt ITLgTa6nLVNfpNICLWmqSuuc+XczlFhCnFI8gbPyhOPiRVD/uuKaYxqmYsSP7pBhJ7Il tUmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dgyZ8Azr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t29-20020a056a00139d00b006c507a60e2dsi9880354pfg.177.2023.11.27.02.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:11:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dgyZ8Azr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9612E802BD4E; Mon, 27 Nov 2023 02:11:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232732AbjK0KLd (ORCPT + 99 others); Mon, 27 Nov 2023 05:11:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232675AbjK0KLc (ORCPT ); Mon, 27 Nov 2023 05:11:32 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55590E1; Mon, 27 Nov 2023 02:11:37 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AR7vNnT021251; Mon, 27 Nov 2023 10:11:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=EY/c6/Ci98EonGSNUz6fVfm6jLBxiwZHNUrcbJIhhUc=; b=dgyZ8AzrEPdMj/muYfIY6vmUUgXJ221mbT63cmMQh6IWmaPLdMtfQkcM8HkdYM1Y91Vm e+Eaa7XDLPLUlXzCFdJf8g/Xp6+ILKhodQb38KqIGqseMEabwkqPFmtUbQ0fEfxZa6/X rGhH4S8ArhNtC4HGmEDp7qtcSp8nrEC5478A8GQwRJfvnq6MOJnMYsaqLa7BcAe2q23W f0LplwPmfHnQrstICNVYEIMiYOr6+u639WhfKJZIQet/fOSSJcwixOH9ssYBcjYGi5+7 qzeZBGVubFQlS3Z1D0MF7jfJzZCAxgg2e7O0Smxzvdq7wgQCVeNxvKUCckM3QKdp5wzI WA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uk69uc435-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Nov 2023 10:11:11 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3ARABACA005140 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Nov 2023 10:11:10 GMT Received: from hu-pkondeti-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 27 Nov 2023 02:11:00 -0800 Date: Mon, 27 Nov 2023 15:40:57 +0530 From: Pavan Kondeti To: Mukesh Ojha CC: , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [Patch v6 11/12] pstore/ram: Add ramoops ready notifier support Message-ID: <3636dc3a-b62b-4ff9-bdc3-fec496a804b7@quicinc.com> References: <1700864395-1479-1-git-send-email-quic_mojha@quicinc.com> <1700864395-1479-12-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1700864395-1479-12-git-send-email-quic_mojha@quicinc.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 1IOVxm-ZeU_nBthYVKeJDrGdxnOedH7K X-Proofpoint-GUID: 1IOVxm-ZeU_nBthYVKeJDrGdxnOedH7K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-27_08,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311270070 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 02:11:47 -0800 (PST) On Sat, Nov 25, 2023 at 03:49:54AM +0530, Mukesh Ojha wrote: > Client like minidump, is only interested in ramoops > region addresses/size so that it could register them > with its table and also it is only deals with ram > backend and does not use pstorefs to read the records. > Let's introduce a client 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 | 77 ++++++++++++++++++++++++++++++++++++++++++++++ > include/linux/pstore_ram.h | 6 ++++ > 2 files changed, 83 insertions(+) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index a6c0da8cfdd4..72341fd21aec 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > #include "ram_internal.h" > @@ -101,6 +102,14 @@ struct ramoops_context { > unsigned int ftrace_read_cnt; > unsigned int pmsg_read_cnt; > struct pstore_info pstore; > + /* > + * Lock to serialize calls to register_ramoops_ready_notifier, > + * ramoops_ready_notifier and read/modification of 'ramoops_ready'. > + */ > + struct mutex lock; > + bool ramoops_ready; > + int (*callback)(const char *name, int id, void *vaddr, > + phys_addr_t paddr, size_t size); > }; > > static struct platform_device *dummy; > @@ -488,6 +497,7 @@ static int ramoops_pstore_erase(struct pstore_record *record) > } > > static struct ramoops_context oops_cxt = { > + .lock = __MUTEX_INITIALIZER(oops_cxt.lock), > .pstore = { > .owner = THIS_MODULE, > .name = "ramoops", > @@ -662,6 +672,68 @@ static int ramoops_init_prz(const char *name, > return 0; > } > > +void ramoops_ready_notifier(struct ramoops_context *cxt) > +{ > + struct persistent_ram_zone *prz; > + int i; > + > + if (!cxt->callback) > + return; > + > + for (i = 0; i < cxt->max_dump_cnt; i++) { > + prz = cxt->dprzs[i]; > + cxt->callback("dmesg", i, prz->vaddr, prz->paddr, prz->size); > + } > + > + if (cxt->console_size) { > + prz = cxt->cprz; > + cxt->callback("console", 0, prz->vaddr, prz->paddr, prz->size); > + } > + > + for (i = 0; i < cxt->max_ftrace_cnt; i++) { > + prz = cxt->fprzs[i]; > + cxt->callback("ftrace", i, prz->vaddr, prz->paddr, prz->size); > + } > + > + if (cxt->pmsg_size) { > + prz = cxt->mprz; > + cxt->callback("pmsg", 0, prz->vaddr, prz->paddr, prz->size); > + } > +} > + > +int register_ramoops_ready_notifier(int (*fn)(const char *, int, > + void *, phys_addr_t, size_t)) > +{ > + struct ramoops_context *cxt = &oops_cxt; > + > + mutex_lock(&cxt->lock); > + if (cxt->callback) { > + mutex_unlock(&cxt->lock); > + return -EEXIST; > + } > + > + cxt->callback = fn; > + if (cxt->ramoops_ready) > + ramoops_ready_notifier(cxt); > + > + mutex_unlock(&cxt->lock); > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(register_ramoops_ready_notifier); > + Can you please elaborate on why do we need this custom notifier logic? why would not a standard notifier (include/linux/notifier.h) work here? The notifier_call callback can recieve custom data from the notifier chain implementer. All we need is to define a custom struct like struct pstore_ramoops_zone_data { const char *name; int id; void *vaddr; phys_addr_t paddr; size_t size; }; and pass the pointer to array of this struct. btw, the current logic only supports just one client and this limitation is not highlighted any where. Thanks, Pavan