From patchwork Tue Mar 1 06:35:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 8462341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2102D9F314 for ; Tue, 1 Mar 2016 06:39:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F35E202EC for ; Tue, 1 Mar 2016 06:39:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A89D202D1 for ; Tue, 1 Mar 2016 06:39:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aadvt-0002eD-RQ; Tue, 01 Mar 2016 06:37:21 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aadvq-0002Y6-96 for linux-arm-kernel@lists.infradead.org; Tue, 01 Mar 2016 06:37:19 +0000 Received: by mail-pf0-x22e.google.com with SMTP id w128so62211931pfb.2 for ; Mon, 29 Feb 2016 22:36:58 -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=/ksq7/rDhzG/nyT3cbLPuofwjDIXwZ6LpCosDoocLGA=; b=I4RiAgLLF0jii5wHNkVh/n/AprGdM4NVrSHZvso3qlAYhrZcfHNctAChplznupqEtT E/P2A7QunbmJFi/YgVNaKJedmSoWlVOdLyCxLfy4V6krJl5VuxIyYMwtAweDlR/U/Nax 2d9UJZr2pUpggwwA7m1fIcaSJey7+xa//WI7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/ksq7/rDhzG/nyT3cbLPuofwjDIXwZ6LpCosDoocLGA=; b=TgeqMI66Yfg2S7DQ0HbHRwZCpBMsy8/vrZtMe4Gi7F7jtht/d+30jm7mxCNlzlkY2w f7wMynxijxrZgdvF8WpNo290m5TSGoCCjgLkrESwHFQrguVLM9a9oXuQXUHKmt8cajYS 4TLWLEQwZlM0Qx8QyNAfF6xJeeilQdR5YfdtdYlYgZDIfffCDiXFQ+5n+fIz+o/eK0uq 4VUmBK/WeX6deGrXt+xUgazY0LoeWr8OtB7ZxG2uPtjzV89Q2IBy6K4O6/VtzLfCdm6k m00AtHhz2Cotrfi8IkY56UF9Sfzl2eoI4owpQSsLQRnJFjekcTP+xIR7NR4vMl0vL1CI WoWQ== X-Gm-Message-State: AD7BkJL5BnjDPn/znE+1A/C905vndQX4SyAppbEDf1w8IPBgl76BRqLV+whhZO21P/4RqsCA X-Received: by 10.98.79.9 with SMTP id d9mr27189012pfb.46.1456814217626; Mon, 29 Feb 2016 22:36:57 -0800 (PST) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id y21sm26485895pfa.85.2016.02.29.22.36.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 22:36:56 -0800 (PST) From: Chunyan Zhang To: mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com Subject: [PATCH V4 1/4] stm class: provision for statically assigned masterIDs Date: Tue, 1 Mar 2016 14:35:06 +0800 Message-Id: <1456814109-21311-2-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456814109-21311-1-git-send-email-zhang.chunyan@linaro.org> References: <1456814109-21311-1-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160229_223718_470306_3376F110 X-CRM114-Status: GOOD ( 18.17 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: al.grant@arm.com, Michael.Williams@arm.com, linux-doc@vger.kernel.org, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org, tor@ti.com, mike.leach@arm.com, linux-api@vger.kernel.org, pratikp@codeaurora.org, nicolas.guion@st.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mathieu Poirier Some architecture like ARM assign masterIDs at the HW design phase. Those are therefore unreachable to users, making masterID management in the generic STM core irrelevant. In this kind of configuration channels are shared between masters rather than being allocated on a per master basis. This patch adds a new 'mshared' flag to struct stm_data that tells the core that this specific STM device doesn't need explicit masterID management. In the core sw_start/end of masterID are set to '1', i.e there is only one masterID to deal with. Also this patch depends on [1], so that the number of masterID is '1' too. Finally the lower and upper bound for masterIDs as presented in ($SYSFS)/class/stm/XYZ.stm/masters and ($SYSFS)/../stp-policy/XYZ.stm.my_policy/some_device/masters are set to '-1'. That way users can't confuse them with architecture where masterID management is required (where any other value would be valid). [1] https://lkml.org/lkml/2015/12/22/348 Signed-off-by: Mathieu Poirier Signed-off-by: Chunyan Zhang --- drivers/hwtracing/stm/core.c | 18 ++++++++++++++++-- drivers/hwtracing/stm/policy.c | 18 ++++++++++++++++-- include/linux/stm.h | 8 ++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c index b6445d9..7f71d54 100644 --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -44,9 +44,15 @@ static ssize_t masters_show(struct device *dev, char *buf) { struct stm_device *stm = to_stm_device(dev); - int ret; + int ret, sw_start, sw_end; + + sw_start = stm->data->sw_start; + sw_end = stm->data->sw_end; - ret = sprintf(buf, "%u %u\n", stm->data->sw_start, stm->data->sw_end); + if (stm->data->mshared) + sw_start = sw_end = STM_SHARED_MASTERID; + + ret = sprintf(buf, "%d %d\n", sw_start, sw_end); return ret; } @@ -618,7 +624,15 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data, if (!stm_data->packet || !stm_data->sw_nchannels) return -EINVAL; + /* + * MasterIDs are assigned at HW design phase. As such the core is + * using a single master for interaction with this device. + */ + if (stm_data->mshared) + stm_data->sw_start = stm_data->sw_end = 1; + nmasters = stm_data->sw_end - stm_data->sw_start; + stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL); if (!stm) return -ENOMEM; diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c index 17a1416..19455db 100644 --- a/drivers/hwtracing/stm/policy.c +++ b/drivers/hwtracing/stm/policy.c @@ -80,10 +80,17 @@ static ssize_t stp_policy_node_masters_show(struct config_item *item, char *page) { struct stp_policy_node *policy_node = to_stp_policy_node(item); + struct stm_device *stm = policy_node->policy->stm; + int first_master, last_master; ssize_t count; - count = sprintf(page, "%u %u\n", policy_node->first_master, - policy_node->last_master); + first_master = policy_node->first_master; + last_master = policy_node->last_master; + + if (stm && stm->data->mshared) + first_master = last_master = STM_SHARED_MASTERID; + + count = sprintf(page, "%d %d\n", first_master, last_master); return count; } @@ -106,6 +113,13 @@ stp_policy_node_masters_store(struct config_item *item, const char *page, if (!stm) goto unlock; + /* + * masterIDs are allocated in HW, no point in trying to + * change their values. + */ + if (stm->data->mshared) + goto unlock; + /* must be within [sw_start..sw_end], which is an inclusive range */ if (first > INT_MAX || last > INT_MAX || first > last || first < stm->data->sw_start || diff --git a/include/linux/stm.h b/include/linux/stm.h index 9d0083d..6fac8b1 100644 --- a/include/linux/stm.h +++ b/include/linux/stm.h @@ -18,6 +18,11 @@ #include /** + * The masterIDs are set in hardware and can't be queried + */ +#define STM_SHARED_MASTERID -1 + +/** * enum stp_packet_type - STP packets that an STM driver sends */ enum stp_packet_type { @@ -46,6 +51,8 @@ struct stm_device; * struct stm_data - STM device description and callbacks * @name: device name * @stm: internal structure, only used by stm class code + * @mshared: true if masterIDs are assigned in HW. If so @sw_start + * and @sw_end are set to '1' by the core. * @sw_start: first STP master available to software * @sw_end: last STP master available to software * @sw_nchannels: number of STP channels per master @@ -71,6 +78,7 @@ struct stm_device; struct stm_data { const char *name; struct stm_device *stm; + bool mshared; unsigned int sw_start; unsigned int sw_end; unsigned int sw_nchannels;