Received: by 10.192.165.148 with SMTP id m20csp4711468imm; Tue, 1 May 2018 02:16:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrNvDoUr1q9wUoWDkeEOmBdzP8x+kBXmMhpb7UgHo5Mqsr5xjRgYSqqa6EcRnEdqnDhJ/Is X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr5790426pld.118.1525166179324; Tue, 01 May 2018 02:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525166179; cv=none; d=google.com; s=arc-20160816; b=xkujUK1tJ+rCqdvAGd0LZU0KicSh/Ol2tEQGlZgHx8dXgxn5egxWwLbwUdOZJtbVcY RHJZFes7a4+j3+AsLdfDK+4eNi/OulgvNNI5cBdJ7W2GWn1y5RYNDnqPG2yMclvwUJ4Y OhqfybRRuIhujn77DzxMo7KJExD037axKpzRHQJBfFbTFQ7oq+bGuzduOkrAgvRFAIdE gupGfWXv089aHq71MW38cZgNyjalMosfe2VoOwMYp8lgd+pOzTEiaxQh/uhYRCZID3Q7 kczX2kbMTLDMcqd4kqPjrNGHaeU8dzd6mdFDB68NvsrQQ3OXu+pJipZNf340iro9dO16 63xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1NMj6jnedx3zzXcR6E4rkLKijuJob1zrTmCOeAf7DG8=; b=KPlMybX16u7TuP1Rp1r1ze2ZhWF0+hQY+9U7yDQqMKQduOEJSGzFizrpH5khq+T6HV btuMICcyeMEq7BzcEdylSKHgK6oDK655usdkakYrlwHxhFQp6txLuAkIrH7XWrdSvNB0 M3Zac5gSo6zg3qLi+vYk5/HHn778hvI3u9CuoFCFDcNnQTg4/L796FTA+18SNm6d152x gbD6cLnr1dt9FYf/kF3cn5tc7tQvJ4iHj19ULZVE49Y0P2qvzuMEGEGt9txKDDpzUx0n rLc14n2zkuh4cktqP3drifZGw/Hg/GLb5uK8GaCetE5x3OGMcpfohYMKQK8jdUriCRTH V1pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si8862028plw.299.2018.05.01.02.16.05; Tue, 01 May 2018 02:16:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755500AbeEAJOG (ORCPT + 99 others); Tue, 1 May 2018 05:14:06 -0400 Received: from foss.arm.com ([217.140.101.70]:44266 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754932AbeEAJL7 (ORCPT ); Tue, 1 May 2018 05:11:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DC712169F; Tue, 1 May 2018 02:11:58 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A85653F487; Tue, 1 May 2018 02:11:56 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, mike.leach@linaro.org, robert.walker@arm.com, mark.rutland@arm.com, will.deacon@arm.com, robin.murphy@arm.com, sudeep.holla@arm.com, frowand.list@gmail.com, robh@kernel.org, john.horley@arm.com, Suzuki K Poulose Subject: [PATCH v2 20/27] coresight: tmc: Add configuration support for trace buffer size Date: Tue, 1 May 2018 10:10:50 +0100 Message-Id: <1525165857-11096-21-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> References: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we can dynamically switch between contiguous memory and SG table depending on the trace buffer size, provide the support for selecting an appropriate buffer size. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- .../ABI/testing/sysfs-bus-coresight-devices-tmc | 8 ++++++ drivers/hwtracing/coresight/coresight-tmc.c | 33 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc index 4fe677e..ea78714 100644 --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc @@ -83,3 +83,11 @@ KernelVersion: 4.7 Contact: Mathieu Poirier Description: (R) Indicates the capabilities of the Coresight TMC. The value is read directly from the DEVID register, 0xFC8, + +What: /sys/bus/coresight/devices/.tmc/buffer_size +Date: August 2018 +KernelVersion: 4.18 +Contact: Mathieu Poirier +Description: (RW) Size of the trace buffer for TMC-ETR when used in SYSFS + mode. Writable only for TMC-ETR configurations. The value + should be aligned to the kernel pagesize. diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index c7bc681..4d41b4b 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -288,8 +288,41 @@ static ssize_t trigger_cntr_store(struct device *dev, } static DEVICE_ATTR_RW(trigger_cntr); +static ssize_t buffer_size_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); + + return sprintf(buf, "%#x\n", drvdata->size); +} + +static ssize_t buffer_size_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + int ret; + unsigned long val; + struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); + + /* Only permitted for TMC-ETRs */ + if (drvdata->config_type != TMC_CONFIG_TYPE_ETR) + return -EPERM; + + ret = kstrtoul(buf, 0, &val); + if (ret) + return ret; + /* The buffer size should be page aligned */ + if (val & (PAGE_SIZE - 1)) + return -EINVAL; + drvdata->size = val; + return size; +} + +static DEVICE_ATTR_RW(buffer_size); + static struct attribute *coresight_tmc_attrs[] = { &dev_attr_trigger_cntr.attr, + &dev_attr_buffer_size.attr, NULL, }; -- 2.7.4