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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4E4FC433EF for ; Thu, 26 May 2022 17:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OHRbIDRvb1eyh0bFrmgp15T9Cvay8ubWrf9FquvkyEU=; b=zo+aym6VjAxU7f YWnqJSKExZxrOhGo2No9/XABnKBDCTWeWui3JoHsh2cFuHTUB9Ahd8IzN6vvAiEm3h9CvL0pg9B3S 8MFoXmJhGnnWFAlKDEP2ADM6z/XcJs8VXka+oyuQBExbOM0o5rMaQUfFAlg6BL45aNkIIytWBq/RM uoO03eXVfT3+IERK/ysyAoAwGLbO/1ph+7thsFhFphPSrhQqoc/245pfKtn0IoJkY08EzCHwJWu2B ziVIAhQ11FRO6iQvvkyBRZUp725cOll9PHrSv15dacd6n6Th0zMSMaM8PuhtG0W0+w0MpQp7X2GO5 R8MtAflKLRpICOJLUx4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuHbD-00FX9T-9e; Thu, 26 May 2022 17:48:39 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuHbA-00FX8Z-6u for linux-arm-kernel@lists.infradead.org; Thu, 26 May 2022 17:48:38 +0000 Received: by mail-pf1-x42e.google.com with SMTP id f21so2279413pfa.3 for ; Thu, 26 May 2022 10:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QFlAkC2pi7BewoIdLtT0sQaUYboAWFiVGvEZq5GKXh8=; b=PebTL56i/ENCxuNMevrZ+aJSWV7CWkjG7+OReRQY21XUPBaSglnxzkipiewH2cx6RS It7XuZ9CK2ZcR9m40a/po6Lef1dxzc/rir3q6dbvmE1WUuPb5K0EPRRa+T+r+/kKix7k JS7O94h8zgV6PJOYCIKG2sdtSgaBlyUD8HUvo7cWkYfVB5TppBy+64QGQ9bIepFHjMbw uOOHyRCDRJxbiP+Twg4OmsivWz4c6cnvYJ/bN9q2PWWEXTBNsMHHGF5vo+z3LVkuCjUH kuf9Ve57zj3Pg7fFRipMzJARpN19+ZQVcrGLznuEFRdDi0xAn5H7qAKTqEcn42pG88oD itcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QFlAkC2pi7BewoIdLtT0sQaUYboAWFiVGvEZq5GKXh8=; b=IRoyARuymHl3rIzNIVM3U25yvyACbmDgNIJ5lq1LS7xPb3V/HKg+o+O5x+ALfNKFV4 WNBh3bCZev5rPUwuSnLuVqkZgGEjQ0zS2F3n8g02RVNZ+ai7ZuPJJk3pli0AEVNMFVSL KMuZR0t9547/0cZLA6xgXPDmm7zJ6T+pbly7I8Oo91AUgrdIscClQuMx7vqMqCEg++bz 1QdfJyvRZN7sxt71KkSBW1BLcy7UEUWkaX7Yo2h6sLu6mi3ZV7TymgYBWCF5yffFCAsl avNMnK55Nfgbm7CAnceoPetLVYkV9lM95L9s5kWqAhIA7ruK62c8GQSyuRitmCp6dP3T WRJQ== X-Gm-Message-State: AOAM532wF+JBpDpygW4h8yFYUiP1U8ZVT/lqaDFr2FPQtklen9t7U64W 73+SI64uEUuPXjvCz5aOCw30xQ== X-Google-Smtp-Source: ABdhPJyGqNRLeG9UFZs6MwSTyDJBR5Vn9G8o9mYog9EVYgRLYKFRjOwOKFXnLCwR9EBx5cbWpve/tQ== X-Received: by 2002:a63:225b:0:b0:3fa:beab:211d with SMTP id t27-20020a63225b000000b003fabeab211dmr10762266pgm.350.1653587313117; Thu, 26 May 2022 10:48:33 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id gd7-20020a17090b0fc700b001df51dd0c93sm3928143pjb.1.2022.05.26.10.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 10:48:32 -0700 (PDT) Date: Thu, 26 May 2022 11:48:30 -0600 From: Mathieu Poirier To: Mike Leach Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, suzuki.poulose@arm.com, leo.yan@linaro.org Subject: Re: [PATCH v3 5/5] Documentation: coresight: docs for config load via configfs Message-ID: <20220526174830.GB309576@p14s> References: <20220414064457.12052-1-mike.leach@linaro.org> <20220414064457.12052-6-mike.leach@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220414064457.12052-6-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220526_104836_295417_574D7850 X-CRM114-Status: GOOD ( 40.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 14, 2022 at 07:44:57AM +0100, Mike Leach wrote: > Add documentation covering the configfs updates that allow > binary configuration files to be loaded and unloaded via configfs, > along with the demonstration programs in samples. > > Signed-off-by: Mike Leach > --- > .../trace/coresight/coresight-config.rst | 166 +++++++++++++++++- > 1 file changed, 160 insertions(+), 6 deletions(-) > > diff --git a/Documentation/trace/coresight/coresight-config.rst b/Documentation/trace/coresight/coresight-config.rst > index 6d5ffa6f7347..9354cfcc04e3 100644 > --- a/Documentation/trace/coresight/coresight-config.rst > +++ b/Documentation/trace/coresight/coresight-config.rst > @@ -152,7 +152,7 @@ follows:: > > $ cd configurations/ > $ ls > - autofdo > + autofdo last_load_status load unload "last_load_status" has been removed. > $ cd autofdo/ > $ ls > description feature_refs preset1 preset3 preset5 preset7 preset9 > @@ -278,9 +278,16 @@ Creating and Loading Custom Configurations > ========================================== > > Custom configurations and / or features can be dynamically loaded into the > -system by using a loadable module. > +system by using a loadable module, or by loading a binary configuration > +file in configfs. > + > +Loaded configurations can use previously loaded features. The system will > +ensure that it is not possible to unload a feature that is currently in > +use, by enforcing the unload order as the strict reverse of the load order. > + > > -An example of a custom configuration is found in ./samples/coresight. > +Using a Loadable Module > +----------------------- > > This creates a new configuration that uses the existing built in > strobing feature, but provides a different set of presets. > @@ -289,6 +296,153 @@ When the module is loaded, then the configuration appears in the configfs > file system and is selectable in the same way as the built in configuration > described above. > > -Configurations can use previously loaded features. The system will ensure > -that it is not possible to unload a feature that is currently in use, by > -enforcing the unload order as the strict reverse of the load order. > +The file 'coresight-cfg-sample.c' contains the configuration and module > +initialisation code needed to create the loadable module. > + > +This will be built alongside the kernel modules if select in KConfig. > + > +An example of a custom configuration module is found in './samples/coresight'. > + > +Using a Binary Configuration File > +--------------------------------- > + > +The './tools/coresight' directory contains example programs to generate and > +read and print binary configuration files. > + > +Building the tools creates the 'coresight-cfg-file-gen' program that will > +generate a configuration binary 'example1.cscfg' that can be loaded into the > +system using configfs. The configuration declared in the source file > +'coresight-cfg-example1.c' is named 'autofdo3' - the name that will be used > +once loaded. > + > +The source files 'coresight-cfg-bufw.h' and 'coresight-cfg-bufw.c' provide a > +standard function to convert a configuration declared in 'C' into the correct > +binary buffer format. These files can be re-used to create new custom > +configurations. Alternatively, addition examples can be added to the > +'coresight-cfg-file-gen' program:: > + > + $ ./coresight-cfg-file-gen > + Coresight Configuration file Generator > + Generating example1 example > + > +The program 'coresight-cfg-file-read' can read back and print a configuration > +binary. This is built using the file reader from the driver code > +(coresight-config-file.c), which is copied over into './tools/coresight' at > +build time.:: > + > + ./coresight-cfg-file-read example1.cscfg > + CoreSight Configuration file reader > + > + Configuration name : autofdo3 > + Uses 1 features:- > + Feature-1: strobing > + > + Provides 4 sets of preset values, 2 presets per set > + set[0]: 0x7d0, 0x64, > + set[1]: 0x7d0, 0x3e8, > + set[2]: 0x7d0, 0x1388, > + set[3]: 0x7d0, 0x2710, > + > + File contains no features > + > +There are additional attributes in the configurations directory - load and > +unload that can be used to load and unload configuration binary files. To > +load, 'cat' the binary config into the load attribute:: > + > + $ ls /config/cs-syscfg/configurations/ > + autofdo load unload > + $ cat example1.cscfg > /config/cs-syscfg/configurations/load > + $ ls /config/cs-syscfg/configurations/ > + autofdo autofdo3 last_load_status load unload Same More comments tomorrow. Thanks, Mathieu > + > +To unload, use the same file in the unload attribute:: > + > + $ cat example1.cscfg > /config/cs-syscfg/configurations/unload > + ls /config/cs-syscfg/configurations/ > + autofdo load unload > + > + > + > +Binary Configuration File Format > +-------------------------------- > + > +The file format is defined in the source file **coresight-config-file.h** > + > +The source reader and generator examples produce a binary of this format. > + > +This arrangement is reproduced below:- > + > +Overall File structure > +~~~~~~~~~~~~~~~~~~~~~~ > + > +:: > + > + [cscfg_file_header] // Mandatory > + [CONFIG_ELEM] // Optional - one per file, if present, first element in file. > + [FEATURE_ELEM]* // Optional - multiple, defined by cscfg_file_header.nr_features > + > +File is invalid if both [CONFIG_ELEM] and [FEATURE_ELEM] are omitted. > + > +A file that contains only [FEATURE_ELEM] may be loaded, and the features used > +by subsequently loaded files with [CONFIG_ELEM] elements. > + > +Where [CONFIG_ELEM] is present, then **cscfg_file_header.nr_features** and > +**CONFIG_ELEM.nr_feat_refs** must have the same value. > + > +CONFIG_ELEM element > +~~~~~~~~~~~~~~~~~~~ > + > +:: > + > + [cscfg_file_elem_header] // header length value to end of feature strings. > + [cscfg_file_elem_str] // name of the configuration. > + [cscfg_file_elem_str] // description of configuration. > + [u16 value](nr_presets) // number of defined presets. > + [u32 value](nr_total_params) // total parameters defined by all used features. > + [u16 value](nr_feat_refs) // number of features referenced by the configuration > + [u64 values] * (nr_presets * nr_total_params) // the preset values. > + [cscfg_file_elem_str] * (nr_feat_refs) // the features used in the configurations. > + > +FEATURE_ELEM element > +~~~~~~~~~~~~~~~~~~~~ > + > +:: > + > + [cscfg_file_elem_header] // header length is total bytes to end of param structures. > + [cscfg_file_elem_str] // feature name. > + [cscfg_file_elem_str] // feature description. > + [u32 value](match_flags) // flags to associate the feature with a device. > + [u16 value](nr_regs) // number of registers. > + [u16 value](nr_params) // number of parameters. > + [cscfg_regval_desc struct] * (nr_regs) // register definitions > + [PARAM_ELEM] * (nr_params) // parameters definitions > + > +PARAM_ELEM element > +~~~~~~~~~~~~~~~~~~ > + > +:: > + > + [cscfg_file_elem_str] // parameter name. > + [u64 value](param_value] // initial value. > + > +Additional definitions. > +~~~~~~~~~~~~~~~~~~~~~~~ > + > +The following structures are defined in **coresight-config-file.h** > + > + * **struct cscfg_file_header** : This structure contains an initial magic number, the total > + length of the file, and the number of features in the file. > + * **struct cscfg_file_elem_header**: This defines the total length and type of a CONFIG_ELEM > + or a FEATURE_ELEM. > + * **struct cscfg_file_elem_str**: This defines a string and its length. > + > +The magic number in cscfg_file_header is defined as two bitfields:: > + > + [31:8] Fixed magic number to identify file type. > + [7:0] Current file format version. > + > +The following defines determine the maximum overall file size and maximum individual > +string size:: > + > + CSCFG_FILE_MAXSIZE // maximum overall file size. > + CSCFG_FILE_STR_MAXSIZE // maximum individual string size. > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel