Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp676121rwb; Thu, 1 Dec 2022 07:07:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6NUcfWg/1soPpJAPNXR9rQ7hmRVWVG732KEnOrR4VtfF1AJ8leG9Iw56RhPRdpJNNMKAPg X-Received: by 2002:a17:907:d092:b0:7ad:7e85:8056 with SMTP id vc18-20020a170907d09200b007ad7e858056mr55691393ejc.40.1669907238162; Thu, 01 Dec 2022 07:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669907238; cv=none; d=google.com; s=arc-20160816; b=VIG4IpMucbkYF62Anqe5f+r8cb07FlaXiLyyyv8z7DsJntRnidqwCl/WFx693gb+wR 5vlhEb1dLasNfvbc+3AScABq0XctVQ74CfcvnRPdOK16WNNkNyMgAxSwxL77bmH74OWa Qjtw0Y07OiHBjpCGBBcfVzGa+OppLhLtIK5AODa87ZM0zGsmimQ1qvy8VXEyrPHeJWRo qsKk42vOY/qV2PQxeoibIcWhpN4CxijpsdqAkVBDwEw939rsgKoJ1ETjllkjIdguoNym TCD/aFHamOjCSuenzMFUblNOde4RYW4s2GK3+npYSWk9iKz2qLAyf/7Rl061M6b1T5Fm U5/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=RlCdeypnvXkqcRc9BhSpFiV8V25y5syjNwmVQBZ7jiA=; b=0u1zIv9FhNKOgzC5922sggrtRUYfJJMaWkt7W9seke0VSNBacH/6/yoW7gFitqdrUq kcc3pk57Yq+OaynUXnX33305pwLqb47iZ8sFNEZA1u80nzckZ6wVIWie9HNgh8jR+0df XrjFbuer2IRytq71r1D1Dfg5CW3qCxDFCS0WN0nATCO8xy1X0RxdgAjCOdBLPYG7sxEV tB3EySW9yhR8SL/yztLoDXuYnld2J3tby9F2b1Ia4o9Ol8O6zSeu8sdjBaejl/sUxyiZ mzI/xkhVHZH6qx7gL8/Zyf8YVgYukuzMTmt/XqA40qbfQP3fllfdHmq9Rd3DDmCbTsE+ Govw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wy1-20020a170906fe0100b007a92b00c075si4318052ejb.891.2022.12.01.07.06.56; Thu, 01 Dec 2022 07:07:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbiLAOhf (ORCPT + 83 others); Thu, 1 Dec 2022 09:37:35 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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; > +} > + >