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 7A331C4332F for ; Wed, 12 Jan 2022 17:24:27 +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=jwOL78moPBe6ZLi7LndFAdiouxuFxLevRuPb4FssBqE=; b=4Khrw/iK/19kZ0 L9gXrQh3H7qpkTcGmIWJvf4WVnI+vC5dMFfba+gHKjW6Tp6Nw337S9YcAAIUnivzahA7Z4zPuu1NY UH6VcIejYzEK83fqmxet4KWt4rE1ihEtDWYheI5E44FyHS/fgABpvWrTtSk56BYtKE/IDJDgJ9ztu S1tULOnA27b0JQeFH09p2KznnNe7XORPm353eeG9aHDf7xnPtpJSu3tlXhRw30ZzjNPQDg+vKFiNY 4XgjU7xTqOMBMyYjEmEOQNpuVArk/lf2TZ+PswpG+9G+NZvCsJqBCJW4+yAqbCv6jdSR2OSzK3Zzq 8qHBZUwpB2pdEMjT49EQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7hKs-003E6M-36; Wed, 12 Jan 2022 17:22:58 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7hKo-003E5Z-F3 for linux-arm-kernel@lists.infradead.org; Wed, 12 Jan 2022 17:22:56 +0000 Received: by mail-pl1-x632.google.com with SMTP id g5so4890098plo.12 for ; Wed, 12 Jan 2022 09:22:53 -0800 (PST) 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=yW2R7swCtal9Go21G705rXRR2nGvM/SvmSSwXgA7hCI=; b=I8CXGXX3HGeXKQiz6YwxXKEOpZtBt9QLSTVYfsZpByVpXXIWFHwp4nC1EZV9bsWSyU wSL7kfwijDchtGYPqfSgqgtqQEsoiNr8S8asdVg50bLBWP5ZKEAR6X0yozrIZs7hd92y aPeKcn+xxXozkjNRG1LUTSCNObTH4tfymIAn2/FXNyK5tBA64bz68P5J1lTB9+GBZ7QD KKcsy1J6GAnm2H0u2h1sNJe5FsZPAfaJt/VdMyOqpc8e+wp57ZFtwpdWkpZv1HhBdfaH N7xljmEq2Hki4oyySIxsYNP7WOgXdmeUdSptlhMqzIFG14jk9SOr0CFK5mKQVrX+uEsg gIwQ== 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=yW2R7swCtal9Go21G705rXRR2nGvM/SvmSSwXgA7hCI=; b=w5pk7zSpjtFpS9G2bQNq3UAe3WrjSAwrPiPVqATAdDJbb35qW3tne21FBg1VmfnfS1 S70cSlNnlLSrDvec11hvu1kQuVr9iMoNPraqojk6pKBdiyDP9OpnUbIBcKJ6i2Ubu0eq syzROr6pLiBlPRnDJADbvBPZGLqRjiw8j9qJurk7KlnA83uTgGcK9oOcBbATvzgv9hDt vfaP+4DMkOv7MRClGDgIobl3Z/loQJCK9BADinbLtpcpG6AtiAk92u9DuTyzFFSq8UFb OlxQfwlkkvxVL5zlyQ0DCqmoCCN6mhLFAFu/BSMyTq3P2FXag58WgsSt2TBA8ayqtcni hUoQ== X-Gm-Message-State: AOAM532rREFy51zIGfPeI+nzoBc3hoX0ryInZ94HA78dl8nEcKaCiCry 3N4s94G30v4tgpYJFIQgGT3xUw== X-Google-Smtp-Source: ABdhPJyfBt/WgOaSNZ0bQGS42S8kvv+A1nNdYfQZ71ClOkv9D62+3O3ZUVI0z7vI+f1x2GlWJKQuKQ== X-Received: by 2002:a63:af05:: with SMTP id w5mr556284pge.595.1642008172605; Wed, 12 Jan 2022 09:22:52 -0800 (PST) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id f10sm222567pfj.145.2022.01.12.09.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 09:22:51 -0800 (PST) Date: Wed, 12 Jan 2022 10:22:49 -0700 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 v2 6/6] Documentation: coresight: docs for config load via configfs Message-ID: <20220112172249.GA892261@p14s> References: <20211130220100.25888-1-mike.leach@linaro.org> <20211130220100.25888-7-mike.leach@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211130220100.25888-7-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220112_092254_537879_DB628C3E X-CRM114-Status: GOOD ( 42.24 ) 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 Hi Mike, On Tue, Nov 30, 2021 at 10:01:00PM +0000, 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 | 151 +++++++++++++++++- > 1 file changed, 145 insertions(+), 6 deletions(-) > > diff --git a/Documentation/trace/coresight/coresight-config.rst b/Documentation/trace/coresight/coresight-config.rst > index 6d5ffa6f7347..f11def230fab 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 > $ cd autofdo/ > $ ls > description feature_refs preset1 preset3 preset5 preset7 preset9 > @@ -278,9 +278,19 @@ 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 module, and generators for binary > +configuration files are found in './samples/coresight'. > > -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 +299,135 @@ 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. > + > + > +Using a Binary Configuration File > +--------------------------------- > + > +Building the samples creates the 'coresight-cfg-filegen' 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-filegen.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. > + > +The program 'coresight-cfg-file-read' can read back and print a configuration > +binary. This is built using the reader from the driver code. > + > +There are additional attributes in the configurations directory - load, unload > +and last_load_status 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 last_load_status load unload > + $ cat example1.cscfg > /config/cs-syscfg/configurations/load > + $ ls /config/cs-syscfg/configurations/ > + autofdo autofdo3 last_load_status load unload > + $ cat /config/cs-syscfg/configurations/last_load_status > + OK: configuration file loaded (autofdo3). > + > +To unload, use the same file in the unload attribute:: > + > + $ cat example1.cscfg > /config/cs-syscfg/configurations/unload > + $ cat /config/cs-syscfg/configurations/last_load_status > + OK: configuration file unloaded (autofdo3). > + ls /config/cs-syscfg/configurations/ > + autofdo last_load_status load unload > + > +The generator and reader programs can also be built directly, separately from > +the kernel build by using the 'Makefile.host' file. This allows native binaries > +to be created on the host machine rather than cross compiled version for the > +target. > + > + > +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. There seems to be a discrepency between the above format and the afdo3 structure definition in sample file coresight-cfg-filegen.c. More comments to come... Thanks, Mathieu > + > +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