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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=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_SANE_1 autolearn=unavailable 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 83ED9C432C0 for ; Wed, 27 Nov 2019 18:27:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 54BC120862 for ; Wed, 27 Nov 2019 18:27:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="g51kS1nS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54BC120862 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9roBFJDpAdp239YmcRHV0a155qEuYcQoMvi7pfcV5PY=; b=g51kS1nSdgRxbOM5TCUqPK6F3 5WxLiaRRESj+pLX8orPAqcMvLRDfEQmc0xtaIhwf0bn0d5OxDHazE5PAHVExsI972fUGWbv+53BQP /VPwGGncBne9yiSwKH0ZBqArdkLbHiGzgxQ4+cD55xjN0RodhXioaxtx027ALyiwYs72hHbLrSt9J DiQmvP6ZkOsBPWDsQmM3cliTn70wekqY003fMPBpzglEooiFqeiT1ZlOau0UdVaA7gp+TxrMHFULn W+ZcBKsR3mAlxNqIbMQTyiura/d18gSjEGE6bTh4IQ4NEZo1gXCwCDg0fiX6MKgqyzcRoUHntlPWm XXyB3rNVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ia21j-0003kC-Pu; Wed, 27 Nov 2019 18:26:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ia21g-0003jO-UD for linux-arm-kernel@lists.infradead.org; Wed, 27 Nov 2019 18:26:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 38F4831B; Wed, 27 Nov 2019 10:26:54 -0800 (PST) Received: from [10.1.197.1] (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6DEC83F6C4; Wed, 27 Nov 2019 10:26:53 -0800 (PST) Subject: Re: [PATCH v5 03/14] coresight: cti: Add sysfs access to program function regs To: Mike Leach , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org References: <20191119231912.12768-1-mike.leach@linaro.org> <20191119231912.12768-4-mike.leach@linaro.org> From: Suzuki Kuruppassery Poulose Message-ID: Date: Wed, 27 Nov 2019 18:26:52 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191119231912.12768-4-mike.leach@linaro.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191127_102657_067833_53FEB388 X-CRM114-Status: GOOD ( 21.45 ) 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: mathieu.poirier@linaro.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 19/11/2019 23:19, Mike Leach wrote: > Adds in sysfs programming support for the CTI function register sets. > Allows direct manipulation of channel / trigger association registers. > > Reviewed-by: Mathieu Poirier > Signed-off-by: Mike Leach > --- > .../hwtracing/coresight/coresight-cti-sysfs.c | 362 ++++++++++++++++++ > drivers/hwtracing/coresight/coresight-cti.c | 19 + > drivers/hwtracing/coresight/coresight-cti.h | 5 + > 3 files changed, 386 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c > index 507f8eb487fe..02d3ee0c1278 100644 > --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c > +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c > @@ -109,6 +109,362 @@ static struct attribute *coresight_cti_mgmt_attrs[] = { > NULL, > }; > > +/* CTI low level programming registers */ > + > +/* > + * Show a simple 32 bit value if enabled and powered. > + * If inaccessible & pcached_val not NULL then show cached value. > + */ Also I am not sure if it makes sense to mention that the value is cached. > +static ssize_t cti_reg32_show(struct device *dev, char *buf, > + u32 *pcached_val, int reg_offset) > +{ > + u32 val = 0; + char *state = ""; > + struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); > + struct cti_config *config = &drvdata->config; > + > + spin_lock(&drvdata->spinlock); > + if ((reg_offset >= 0) && CTI_PWR_ENA(config)) { minor nit: Personally I don't like the naming here. This could simply be: cti_accessible(config) , may be defined as a static inline function instead of a macro: static inline bool cti_accessible(struct cti_drvdata *drvdata) { struct cti_config *cfg = &drvdata->config; return cfg->hw_powered && cfg->hw_enabled; } > + CS_UNLOCK(drvdata->base); > + val = readl_relaxed(drvdata->base + reg_offset); > + if (pcached_val) > + *pcached_val = val; > + CS_LOCK(drvdata->base); > + } else if (pcached_val) { > + val = *pcached_val; + state = " (cached)"; > + } > + spin_unlock(&drvdata->spinlock); > + return scnprintf(buf, PAGE_SIZE, "%#x\n", val); + return scnprintf(buf, PAGE_SIZE, "%#x%s\n", val, state); > +} > + > +/* > + * Store a simple 32 bit value. > + * If pcached_val not NULL, then copy to here too, > + * if reg_offset >= 0 then write through if enabled. > + */ > +static ssize_t cti_reg32_store(struct device *dev, const char *buf, > + size_t size, u32 *pcached_val, int reg_offset) > +static ssize_t appclear_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t size) > +{ > + unsigned long val; > + struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); > + struct cti_config *config = &drvdata->config; > + > + if (kstrtoul(buf, 0, &val)) > + return -EINVAL; > + > + spin_lock(&drvdata->spinlock); > + > + /* a 1'b1 in appclr clears down the same bit in appset*/ nit: a 0b1 ? > + config->ctiappset &= ~val; > + > + /* write through if enabled */ > + if (CTI_PWR_ENA(config)) > + cti_write_single_reg(drvdata, CTIAPPCLEAR, val); > + spin_unlock(&drvdata->spinlock); > + return size; > +} > +static DEVICE_ATTR_WO(appclear); > + Otherwise looks good to me. Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel