From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57D60C43217 for ; Thu, 1 Dec 2022 14:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231782AbiLAOhg (ORCPT ); Thu, 1 Dec 2022 09:37:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbiLAOhd (ORCPT ); Thu, 1 Dec 2022 09:37:33 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFBFA8FD8; Thu, 1 Dec 2022 06:37:31 -0800 (PST) Received: from frapeml100001.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NNJYn3cZMz67KSZ; Thu, 1 Dec 2022 22:37:01 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by frapeml100001.china.huawei.com (7.182.85.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 1 Dec 2022 15:37:28 +0100 Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 1 Dec 2022 14:37:28 +0000 Date: Thu, 1 Dec 2022 14:37:27 +0000 From: Jonathan Cameron To: CC: Dan Williams , Alison Schofield , Vishal Verma , "Ben Widawsky" , Steven Rostedt , Davidlohr Bueso , Dave Jiang , , Subject: Re: [PATCH V2 09/11] cxl/test: Add generic mock events Message-ID: <20221201143727.0000255c@Huawei.com> In-Reply-To: <20221201002719.2596558-10-ira.weiny@intel.com> References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-10-ira.weiny@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Nov 2022 16:27:17 -0800 ira.weiny@intel.com wrote: > From: Ira Weiny > > Facilitate testing basic Get/Clear Event functionality by creating > multiple logs and generic events with made up UUID's. > > Data is completely made up with data patterns which should be easy to > spot in trace output. > > A single sysfs entry resets the event data and triggers collecting the > events for testing. > > Events are returned one at a time which is within the specification even > though it does not exercise the full capabilities of what a device may > do. > > Test traces are easy to obtain with a small script such as this: > > #!/bin/bash -x > > devices=`find /sys/devices/platform -name cxl_mem*` > > # Turn on tracing > echo "" > /sys/kernel/tracing/trace > echo 1 > /sys/kernel/tracing/events/cxl/enable > echo 1 > /sys/kernel/tracing/tracing_on > > # Generate fake interrupt > for device in $devices; do > echo 1 > $device/event_trigger > done > > # Turn off tracing and report events > echo 0 > /sys/kernel/tracing/tracing_on > cat /sys/kernel/tracing/trace > > Signed-off-by: Ira Weiny > A minor comment on xarray cleanup inline Jonathan > +void cxl_mock_remove_event_logs(struct device *dev) > +{ > + struct mock_event_store *mes; > + > + mes = xa_erase(&mock_dev_event_store, (unsigned long)dev); As below, I'd move this into a devm_add_action_or_reset() so that we don't need to deal with doing it manually. > +} > +EXPORT_SYMBOL_GPL(cxl_mock_remove_event_logs); ... > static int cxl_mock_mem_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct cxl_memdev *cxlmd; > struct cxl_dev_state *cxlds; > + u32 ev_status; > void *lsa; > int rc; > > @@ -281,11 +304,13 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) > if (rc) > return rc; > > + ev_status = cxl_mock_add_event_logs(cxlds); On error later in this function these leak. Just use devm_add_action_or_reset() inside cxl_mock_add_event_logs() so we don't have to care about that. > + > cxlmd = devm_cxl_add_memdev(cxlds); > if (IS_ERR(cxlmd)) > return PTR_ERR(cxlmd); > > - cxl_mem_get_event_records(cxlds); > + __cxl_mem_get_event_records(cxlds, ev_status); > > if (resource_size(&cxlds->pmem_res) && IS_ENABLED(CONFIG_CXL_PMEM)) > rc = devm_cxl_add_nvdimm(dev, cxlmd); > @@ -293,6 +318,12 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) > return 0; > } > > +static int cxl_mock_mem_remove(struct platform_device *pdev) > +{ > + cxl_mock_remove_event_logs(&pdev->dev); Why not use devm_add_action_or_reset()? > + return 0; > +} > + >