From patchwork Fri Oct 30 17:56:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11870461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7BB1C00A89 for ; Fri, 30 Oct 2020 17:59:34 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DE1620A8B for ; Fri, 30 Oct 2020 17:59:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oE24SGFU"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lQDOenwp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DE1620A8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ucZPdN0SjoL1c47IOB3Etx+uamUP93JJP4pyw3QaidA=; b=oE24SGFUyfNuzpYta74J2I51Jx eEdN/xl4n4vkGS8Q1fV/FOfrO7GydLzK+jTXvnWMZ+Ja5yDUTALvyVclhG3aeON4d9LbLmPq3w7I8 DyHMMIr5xCqliJ7FGijlxtroAdvTB9ZZhBte8OM0+eJPpOjjkC/IMIpy4o+28FUXIoHsD/rOt1pee 7f2AHBibJwiLPT9RiVfBkVrH8yO9GF5f7w8s4mv9wP8mskz8aqbbvtk4cB13E6L4pLwWgzENCXMTH 08BWLyM7dzlZiEK45+G66CCY9cf4Zoodbkvz9fbp6t0Z6uxgJ1bOFAO7kX/v1P/PRPldunBr3m74k 8h+uzqbg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYYeg-0003vI-TJ; Fri, 30 Oct 2020 17:57:39 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYYeB-0003mg-Fz for linux-arm-kernel@lists.infradead.org; Fri, 30 Oct 2020 17:57:14 +0000 Received: by mail-wm1-x342.google.com with SMTP id k18so3718151wmj.5 for ; Fri, 30 Oct 2020 10:57:07 -0700 (PDT) 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=GGKTje4jPOjb3VM6X5bDiYCSOQcsfHSNonQFBEGHAUE=; b=lQDOenwpVy++4FjT95IudNOY4MANv3ii/sT2gaC9qEnZd3TmEw5aUrTHbi92D34Pds QKEMmVsUDrZ/FEKv2GxvpwwV6HLDf+3cw5zWw1U/t3AOQZRyDICz2B9WlvxCZuYaWfVc gYJZylgBE7k3Iv5TATIhMvX3QvT8WpIofY3IEyaw2Ue4xx9Otou1l20VtFknrc3IqBWX ZIF1WrqHqNV8D2Rvls4U3SRsibqM13L42W9akF17e1zAJuuJ2VA3DbTKR3M8QcJ9hzR9 gO1y295im5inD/CEVhxS54F82cbg9npMdeSks5v/8TIgNnCUlHhHnX4vxdqQ1zaUAxeW +aCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GGKTje4jPOjb3VM6X5bDiYCSOQcsfHSNonQFBEGHAUE=; b=Gy5PEvLsyfIg6Q47cMGbiqIiHYuqAtXb5w1pLKSd09yDo1kNr1HYoTw+Qmf5OtC/kG hnuPqAfUXPp/E7+o06OVLMZk2BfZBOPOjJ286+KwvBR4zGQbHdbtfWllxQG/SwRZpC6M tFpXmgx8ZDZUKpN4WC/MHD1609Hifs4MbXc0JvaROnQyo7kMWsYNx8YpgpQRi+1lhGTH VM4LtqBsqo+tFML+rLHiHrknSlG218ifIUsg+AF/186oMtRz7aayN1z/e/aygHkQrVm5 hvYqa49iu3uKz8XJ6gxhJwltUQp1cQeRMUTPuw9Iu1bGNSRiv0GamaTOo4J3mplK07iu lVnw== X-Gm-Message-State: AOAM531mvjR1RLDo27y3VdLHU5/CMaBHr0rILL4ZsdFH0HejGFyzHrwD bMq0LpeDV/1QJCFXPaRoL63faaykUH5wMw== X-Google-Smtp-Source: ABdhPJxCAf4AKrzxwWwh55W3x6oYkylHgFdeMfrlWM7+GitPiWkGt+4rZQMlc/93AWxFbue2XZUwNQ== X-Received: by 2002:a1c:3846:: with SMTP id f67mr4129432wma.33.1604080626230; Fri, 30 Oct 2020 10:57:06 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:4964:83f8:d2e7:f2c9]) by smtp.gmail.com with ESMTPSA id o129sm5615563wmb.25.2020.10.30.10.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 10:57:05 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [RFC PATCH v3 8/9] coresight: syscfg: Allow update of feature params from configfs Date: Fri, 30 Oct 2020 17:56:54 +0000 Message-Id: <20201030175655.30126-9-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201030175655.30126-1-mike.leach@linaro.org> References: <20201030175655.30126-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201030_135708_675476_BCD3DB50 X-CRM114-Status: GOOD ( 22.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yabinc@google.com, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add in functionality to allow the user to update feature default parameter values from the configfs interface. This updates all the device instances with the new values, removing the need to set all devices individually via sysfs. Signed-off-by: Mike Leach --- .../hwtracing/coresight/coresight-config.c | 36 ++++++++++++++++--- .../hwtracing/coresight/coresight-config.h | 1 + .../coresight/coresight-syscfg-configfs.c | 3 ++ .../hwtracing/coresight/coresight-syscfg.c | 15 ++++++++ .../hwtracing/coresight/coresight-syscfg.h | 1 + 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-config.c b/drivers/hwtracing/coresight/coresight-config.c index 04e7cb4ff769..7d30a415f2ff 100644 --- a/drivers/hwtracing/coresight/coresight-config.c +++ b/drivers/hwtracing/coresight/coresight-config.c @@ -96,6 +96,17 @@ static void cscfg_save_on_disable(struct cscfg_feature_csdev *feat, const bool f spin_unlock(feat->csdev_spinlock); } +/* load default values into params */ +static void cscfg_set_param_defaults(struct cscfg_feature_csdev *feat) +{ + int i; + + spin_lock(&feat->desc->param_lock); + for (i = 0; i < feat->nr_params; i++) + feat->params[i].current_value = feat->desc->params[i].value; + spin_unlock(&feat->desc->param_lock); +} + /* default reset - restore default values, disable feature */ static void cscfg_reset_feat(struct cscfg_feature_csdev *feat) { @@ -111,10 +122,7 @@ static void cscfg_reset_feat(struct cscfg_feature_csdev *feat) * set the default values for all parameters and regs from the * relevant static descriptors. */ - spin_lock(&feat->desc->param_lock); - for (i = 0; i < feat->nr_params; i++) - feat->params[i].current_value = feat->desc->params[i].value; - spin_unlock(&feat->desc->param_lock); + cscfg_set_param_defaults(feat); for (i = 0; i < feat->nr_regs; i++) { reg_desc = &feat->desc->regs[i]; @@ -131,6 +139,26 @@ static void cscfg_reset_feat(struct cscfg_feature_csdev *feat) spin_unlock(feat->csdev_spinlock); } +/* update the parameters in a named feature from their defaults for the supplied device */ +void cscfg_csdev_set_param_defaults(struct coresight_device *csdev, const char *feat_name) +{ + struct cscfg_feature_csdev *feat; + + spin_lock(&csdev->cfg_lock); + if (list_empty(&csdev->feat_list)) { + spin_unlock(&csdev->cfg_lock); + return; + } + + list_for_each_entry(feat, &csdev->feat_list, node) { + if (!strcmp(feat_name, feat->desc->name)) { + cscfg_set_param_defaults(feat); + break; + } + } + spin_unlock(&csdev->cfg_lock); +} + void cscfg_set_def_ops(struct cscfg_feature_csdev *feat) { feat->ops.set_on_enable = cscfg_set_on_enable; diff --git a/drivers/hwtracing/coresight/coresight-config.h b/drivers/hwtracing/coresight/coresight-config.h index 39fcac011aa0..1c6f0f903861 100644 --- a/drivers/hwtracing/coresight/coresight-config.h +++ b/drivers/hwtracing/coresight/coresight-config.h @@ -297,6 +297,7 @@ struct cscfg_csdev_feat_ops { /* helper functions for feature manipulation */ void cscfg_set_def_ops(struct cscfg_feature_csdev *feat); +void cscfg_csdev_set_param_defaults(struct coresight_device *csdev, const char *feat_name); /* enable / disable features or configs on a device */ int cscfg_csdev_set_enabled_feats(struct coresight_device *csdev); diff --git a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c index ff7ea678100a..1595c0c61db1 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c +++ b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c @@ -242,6 +242,9 @@ static ssize_t cscfg_param_value_store(struct config_item *item, param_item->param->value = val; spin_unlock(¶m_item->desc->param_lock); + /* push new value out to devices */ + cscfg_update_named_feat_csdevs(param_item->desc->name); + return size; } CONFIGFS_ATTR(cscfg_param_, value); diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c index 2cf67a038cc8..c42374342806 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -315,6 +315,21 @@ const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name) return feat; } +/* + * Set all parameter defaults for named feature. + * Iterates through csdev list and updates param defaults on named feature. + */ +void cscfg_update_named_feat_csdevs(const char *feat_name) +{ + struct cscfg_csdev_register *curr_item; + + mutex_lock(&cscfg_mutex); + list_for_each_entry(curr_item, &cscfg_data.dev_list, item) { + cscfg_csdev_set_param_defaults(curr_item->csdev, feat_name); + } + mutex_unlock(&cscfg_mutex); +} + /* * External API function to load feature and config sets. * Take a 0 terminated array of feature descriptors and/or configuration diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h index ce237a69677b..d07a0f11097f 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.h +++ b/drivers/hwtracing/coresight/coresight-syscfg.h @@ -48,6 +48,7 @@ int __init cscfg_init(void); void __exit cscfg_exit(void); int cscfg_preload(void); const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name); +void cscfg_update_named_feat_csdevs(const char *feat_name); /* syscfg external API */ int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs,