From patchwork Wed Nov 24 20:00:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 12693580 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 05C83C433F5 for ; Wed, 24 Nov 2021 20:02:49 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5naMioADX4Vulpw+2+IFkXjCZmCtHZe3BI2lK+1iEco=; b=SvN7WwCIjqUsnS eHrbZiqnWV9n6AnSbCjrjz8k2K65ifL1m7DoGSj+C37lE6VIWLqUlEiAzoR8NVI638e+v5o0Y291+ /1YfUCcBB+jBr0gtFn2Ye6CUliXGaQ1YHMDqVmB4WZWsYws3NnTHarNilAImTy7GvNb3QwCbcdAV9 WHMuUHz/OT4hydHoajY/gtyTQMuZkWghZi+Bt7sh3f9AFno8Ua0IdaTWR7TnwbbOoHbTA155lLMnF 5v6FERRshGZlnx2a83pZVIoZ/VAzCCvKagrVXcF4HhYFzKJLCP849RUqg9JxAWbNJoUQir87dTK6b T9WZV4Iwv3GHi26yabsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpySH-005jcv-VF; Wed, 24 Nov 2021 20:01:22 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpyRi-005jR2-NZ for linux-arm-kernel@lists.infradead.org; Wed, 24 Nov 2021 20:00:50 +0000 Received: by mail-wm1-x32f.google.com with SMTP id p18so3540122wmq.5 for ; Wed, 24 Nov 2021 12:00:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7rZS4dOBAE84jxXnsOA/aw9s5xT/+bW788bYxm22cWA=; b=Z5ooGUYX0gzFRcCGHFuOFBSiM5I+hGsU3R0QlNVlunqZqL0WL8HtfgGsZs7cs9QCPe 4g95j1WOa5YzzZlLL+/y9YjzfpvOlOKdX9mXy0mGoJB5rIuUFUd+PAxBYpAeUHSuSlKR 7uyXx7OewK00pMc+scDAj8Zd35lSh9Y8AdaNDCb5lz0TV9p3pwEaCc3b3iAC2qJZefw+ SzAJkeim8QFSoZHsEIKkcqTa5CGIah1D/+Xdb0G7ib6hXfFdCTOU2nkWpxz+DySxsTE9 oF5H6PA768s23v8nNBGGhi7ocbbX71r7kVrY+4hgtBdTrQD8SZRmmse0c1kZP98EuOeT tRmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7rZS4dOBAE84jxXnsOA/aw9s5xT/+bW788bYxm22cWA=; b=QQEh+H42c+7kvOM205mYZW4x+K+ig4dwEOmjGbcc84IzfJdSQkchgLa9/UlwD3j3Vz gt3cwYVUDC6vLjyvjIFqSW+8psiSkbDG42AR5hpCTlS4/C7HEF2R0ku88G2kExZaS0Qu 3+RnBHoScI+nnx4QXfUfIOqG1O0GMU5HpxXymaRMUrf5H8zEQs6kOqG9YTCDoZDBskWu Z6P8YRJpUpBVwhIOc1Wjyzz3snbx5IcQoFi4S98iNVlr7hlwQz2ZHtmpaFVImM1D8Pdk 5+EVhndvsU1kvGkcyW/+i2+P2hy5NbIpxBW/fwe/9k0I/ncoTpoU5EqeUCuythjVgMW/ YrUA== X-Gm-Message-State: AOAM532aPamFndm6QHYq8hlE9VPpJZ0gf/cPQ210ejQ6NnbYlWBHgM6S mpI6cPTWQZNcZZMr5qJugDSHo+4/h9v3AQ== X-Google-Smtp-Source: ABdhPJwgtgvUG7IxJTbJLddfeqRWi8/eV6Kj7T53qJo55RzMZasFIsDrx53cJ7FYfPr3LJ7I94wx1w== X-Received: by 2002:a1c:96:: with SMTP id 144mr19029359wma.126.1637784045065; Wed, 24 Nov 2021 12:00:45 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:dd2e:a6e1:6adf:269c]) by smtp.gmail.com with ESMTPSA id c1sm729582wrt.14.2021.11.24.12.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 12:00:44 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, leo.yan@linaro.org, Mike Leach Subject: [PATCH v3 1/6] coresight: configuration: Update API to introduce load owner concept Date: Wed, 24 Nov 2021 20:00:33 +0000 Message-Id: <20211124200038.28662-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211124200038.28662-1-mike.leach@linaro.org> References: <20211124200038.28662-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211124_120046_813619_870A35C9 X-CRM114-Status: GOOD ( 22.72 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Update the existing load API to introduce a "load owner" concept. This allows the tracking of the loaded configurations and features against the loading owner type, to allow later unload according to owner. A list of loaded configurations by owner is created. The load owner infrastructure will be used in following patches to implement dynanic load and unload, alongside dependency tracking. Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier --- .../coresight/coresight-cfg-preload.c | 9 ++++-- .../hwtracing/coresight/coresight-config.h | 5 +++- .../hwtracing/coresight/coresight-syscfg.c | 21 ++++++++++++-- .../hwtracing/coresight/coresight-syscfg.h | 29 +++++++++++++++++-- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.c b/drivers/hwtracing/coresight/coresight-cfg-preload.c index 751af3710d56..e237a4edfa09 100644 --- a/drivers/hwtracing/coresight/coresight-cfg-preload.c +++ b/drivers/hwtracing/coresight/coresight-cfg-preload.c @@ -24,8 +24,13 @@ static struct cscfg_config_desc *preload_cfgs[] = { NULL }; +static struct cscfg_load_owner_info preload_owner = { + .type = CSCFG_OWNER_PRELOAD, +}; + /* preload called on initialisation */ -int cscfg_preload(void) +int cscfg_preload(void *owner_handle) { - return cscfg_load_config_sets(preload_cfgs, preload_feats); + preload_owner.owner_handle = owner_handle; + return cscfg_load_config_sets(preload_cfgs, preload_feats, &preload_owner); } diff --git a/drivers/hwtracing/coresight/coresight-config.h b/drivers/hwtracing/coresight/coresight-config.h index 25eb6c632692..6e0d43901d66 100644 --- a/drivers/hwtracing/coresight/coresight-config.h +++ b/drivers/hwtracing/coresight/coresight-config.h @@ -97,6 +97,7 @@ struct cscfg_regval_desc { * @params_desc: array of parameters used. * @nr_regs: number of registers used. * @regs_desc: array of registers used. + * @load_owner: handle to load owner for dynamic load and unload of features. */ struct cscfg_feature_desc { const char *name; @@ -107,6 +108,7 @@ struct cscfg_feature_desc { struct cscfg_parameter_desc *params_desc; int nr_regs; struct cscfg_regval_desc *regs_desc; + void *load_owner; }; /** @@ -128,7 +130,7 @@ struct cscfg_feature_desc { * @presets: Array of preset values. * @event_ea: Extended attribute for perf event value * @active_cnt: ref count for activate on this configuration. - * + * @load_owner: handle to load owner for dynamic load and unload of configs. */ struct cscfg_config_desc { const char *name; @@ -141,6 +143,7 @@ struct cscfg_config_desc { const u64 *presets; /* nr_presets * nr_total_params */ struct dev_ext_attribute *event_ea; atomic_t active_cnt; + void *load_owner; }; /** diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c index 43054568430f..021f50949d7b 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -361,13 +361,22 @@ int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc, * descriptors and load into the system. * Features are loaded first to ensure configuration dependencies can be met. * + * To facilitate dynamic loading and unloading, features and configurations + * have a "load_owner", to allow later unload by the same owner. An owner may + * be a loadable module or configuration dynamically created via configfs. + * As later loaded configurations can use earlier loaded features, creating load + * dependencies, a load order list is maintained. Unload is strictly in the + * reverse order to load. + * * @config_descs: 0 terminated array of configuration descriptors. * @feat_descs: 0 terminated array of feature descriptors. + * @owner_info: Information on the owner of this set. */ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs, - struct cscfg_feature_desc **feat_descs) + struct cscfg_feature_desc **feat_descs, + struct cscfg_load_owner_info *owner_info) { - int err, i = 0; + int err = 0, i = 0; mutex_lock(&cscfg_mutex); @@ -382,6 +391,7 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs, feat_descs[i]->name); goto exit_unlock; } + feat_descs[i]->load_owner = owner_info; i++; } } @@ -398,10 +408,14 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs, config_descs[i]->name); goto exit_unlock; } + config_descs[i]->load_owner = owner_info; i++; } } + /* add the load owner to the load order list */ + list_add_tail(&owner_info->item, &cscfg_mgr->load_order_list); + exit_unlock: mutex_unlock(&cscfg_mutex); return err; @@ -827,10 +841,11 @@ int __init cscfg_init(void) INIT_LIST_HEAD(&cscfg_mgr->csdev_desc_list); INIT_LIST_HEAD(&cscfg_mgr->feat_desc_list); INIT_LIST_HEAD(&cscfg_mgr->config_desc_list); + INIT_LIST_HEAD(&cscfg_mgr->load_order_list); atomic_set(&cscfg_mgr->sys_active_cnt, 0); /* preload built-in configurations */ - err = cscfg_preload(); + err = cscfg_preload(THIS_MODULE); if (err) goto exit_err; diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h index 8d018efd6ead..08067e89edcf 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.h +++ b/drivers/hwtracing/coresight/coresight-syscfg.h @@ -25,6 +25,7 @@ * @csdev_desc_list: List of coresight devices registered with the configuration manager. * @feat_desc_list: List of feature descriptors to load into registered devices. * @config_desc_list: List of system configuration descriptors to load into registered devices. + * @load_order_list: Ordered list of owners for dynamically loaded configurations. * @sys_active_cnt: Total number of active config descriptor references. * @cfgfs_subsys: configfs subsystem used to manage configurations. */ @@ -33,6 +34,7 @@ struct cscfg_manager { struct list_head csdev_desc_list; struct list_head feat_desc_list; struct list_head config_desc_list; + struct list_head load_order_list; atomic_t sys_active_cnt; struct configfs_subsystem cfgfs_subsys; }; @@ -56,10 +58,32 @@ struct cscfg_registered_csdev { struct list_head item; }; +/* owner types for loading and unloading of config and feature sets */ +enum cscfg_load_owner_type { + CSCFG_OWNER_PRELOAD, +}; + +/** + * Load item - item to add to the load order list allowing dynamic load and + * unload of configurations and features. Caller loading a config + * set provides a context handle for unload. API ensures that + * items unloaded strictly in reverse order from load to ensure + * dependencies are respected. + * + * @item: list entry for load order list. + * @type: type of owner - allows interpretation of owner_handle. + * @owner_handle: load context - handle for owner of loaded configs. + */ +struct cscfg_load_owner_info { + struct list_head item; + int type; + void *owner_handle; +}; + /* internal core operations for cscfg */ int __init cscfg_init(void); void cscfg_exit(void); -int cscfg_preload(void); +int cscfg_preload(void *owner_handle); const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name); int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc, int param_idx, u64 value); @@ -67,7 +91,8 @@ int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc, /* syscfg manager external API */ int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs, - struct cscfg_feature_desc **feat_descs); + struct cscfg_feature_desc **feat_descs, + struct cscfg_load_owner_info *owner_info); int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags, struct cscfg_csdev_feat_ops *ops); void cscfg_unregister_csdev(struct coresight_device *csdev);