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=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 B5790C433E0 for ; Mon, 3 Aug 2020 09:39:11 +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 7E4F720719 for ; Mon, 3 Aug 2020 09:39:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vUb4bPp9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E4F720719 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+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: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=O3wDci238f+QcHTQhPwAkWpbye91v1kX3/T988mKlq0=; b=vUb4bPp91D4n2dYLZJyCG7jX3 9jAacbtbhf91xnK4D9FW6KD65+LP0ems7u3J3TtsRG3rp2ABKerOBuMlQh1Od5KSe+BuBLSE76aAm axQ8cTDtzrFFQV4/fXqvxbJCYbTTn8ukqH/Y3XmlKxoRHX3r0pdfp411YwG0facE7/X/I8Xtdo5JO lxpkMzNfDogT0dJmHmBuEf8qVSsh3XBuytBGXVoer5WHH9efesb4xQIxwTtnBEnZqbDk+poH5OEom /mxnrvBbAV1IExjA6cXxbMrSXvbyPZrxJ/LKEJVOeVlNYdksPK67xAhH2aT/od9jf2uOEyCftR3ED 2TRdlOqrA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Wum-0007d5-1n; Mon, 03 Aug 2020 09:37:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Wui-0007cP-Dj for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 09:37:49 +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 85FD6D6E; Mon, 3 Aug 2020 02:37:44 -0700 (PDT) Received: from [10.163.64.194] (unknown [10.163.64.194]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 277763F718; Mon, 3 Aug 2020 02:37:41 -0700 (PDT) Subject: Re: [PATCH V2] coresight: Make sysFS functional on topologies with per core sink To: Linu Cherian , mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org References: <20200801090950.19420-1-lcherian@marvell.com> From: Anshuman Khandual Message-ID: Date: Mon, 3 Aug 2020 15:07:17 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200801090950.19420-1-lcherian@marvell.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_053748_592244_50466495 X-CRM114-Status: GOOD ( 37.36 ) 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: coresight@lists.linaro.org, linuc.decode@gmail.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello Linu, Please do mention the tree on which this patch applies on. The coresight API functions being changed here are not even present on v5.8 but instead are part of linux-next (atleast next-20200731). On 08/01/2020 02:39 PM, Linu Cherian wrote: > Coresight driver assumes sink is common across all the ETMs, Does 'common' just implies reachable here. Should not all the sinks on the system be reachable from all the sources. > and tries to build a path between ETM and the first enabled > sink found using bus based search. This breaks sysFS usage > on implementations that has multiple per core sinks in > enabled state. Could you please explain how it breaks the sysfs usage ? Why those per core sinks were not found through existing bus based search. > > For this, > - coresight_find_sink API is updated with an additional flag > so that it is able to return an enabled sink > - coresight_get_enabled_sink API is updated to do a > connection based search, when a source reference is given. > > Change-Id: I6cc91ddb3ef8936a8f41a5f7c7c455b0ece9d85d > Signed-off-by: Linu Cherian > --- > Applies on https://git.linaro.org/kernel/coresight.git/log/?h=next > > Changes in V2: > - Fixed few typos in commit message > - Rephrased commit message > > .../hwtracing/coresight/coresight-etm-perf.c | 2 +- > drivers/hwtracing/coresight/coresight-priv.h | 5 +- > drivers/hwtracing/coresight/coresight.c | 51 +++++++++++++++++-- > 3 files changed, 51 insertions(+), 7 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > index 1a3169e69bb1..25041d2654e3 100644 > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > @@ -223,7 +223,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, > id = (u32)event->attr.config2; > sink = coresight_get_sink_by_id(id); > } else { > - sink = coresight_get_enabled_sink(true); > + sink = coresight_get_enabled_sink(NULL, true); > } > > mask = &event_data->mask; > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h > index f2dc625ea585..010ed26db340 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -148,10 +148,13 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val, > void coresight_disable_path(struct list_head *path); > int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); > struct coresight_device *coresight_get_sink(struct list_head *path); > -struct coresight_device *coresight_get_enabled_sink(bool reset); > +struct coresight_device * > +coresight_get_enabled_sink(struct coresight_device *source, bool reset); > struct coresight_device *coresight_get_sink_by_id(u32 id); > struct coresight_device * > coresight_find_default_sink(struct coresight_device *csdev); > +struct coresight_device * > +coresight_find_enabled_sink(struct coresight_device *csdev); > struct list_head *coresight_build_path(struct coresight_device *csdev, > struct coresight_device *sink); > void coresight_release_path(struct list_head *path); > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index e9c90f2de34a..ae69169c58d3 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -566,6 +566,10 @@ static int coresight_enabled_sink(struct device *dev, const void *data) > > /** > * coresight_get_enabled_sink - returns the first enabled sink found on the bus > + * When a source reference is given, enabled sink is found using connection based > + * search. > + * > + * @source: Coresight source device reference > * @deactivate: Whether the 'enable_sink' flag should be reset > * > * When operated from perf the deactivate parameter should be set to 'true'. > @@ -576,10 +580,21 @@ static int coresight_enabled_sink(struct device *dev, const void *data) > * parameter should be set to 'false', hence mandating users to explicitly > * clear the flag. > */ > -struct coresight_device *coresight_get_enabled_sink(bool deactivate) > +struct coresight_device * > +coresight_get_enabled_sink(struct coresight_device *source, bool deactivate) > { > struct device *dev = NULL; > + struct coresight_device *sink; > + > + if (!source) > + goto bus_search; > + sink = coresight_find_enabled_sink(source); > + if (sink && deactivate) > + sink->activated = false; > + > + return sink; > > +bus_search: > dev = bus_find_device(&coresight_bustype, NULL, &deactivate, > coresight_enabled_sink); > > @@ -828,6 +843,7 @@ coresight_select_best_sink(struct coresight_device *sink, int *depth, > * > * @csdev: source / current device to check. > * @depth: [in] search depth of calling dev, [out] depth of found sink. > + * @enabled: flag to search only enabled sinks > * > * This will walk the connection path from a source (ETM) till a suitable > * sink is encountered and return that sink to the original caller. > @@ -839,7 +855,7 @@ coresight_select_best_sink(struct coresight_device *sink, int *depth, > * return best sink found, or NULL if not found at this node or child nodes. > */ > static struct coresight_device * > -coresight_find_sink(struct coresight_device *csdev, int *depth) > +coresight_find_sink(struct coresight_device *csdev, int *depth, bool enabled) > { > int i, curr_depth = *depth + 1, found_depth = 0; > struct coresight_device *found_sink = NULL; > @@ -862,7 +878,8 @@ coresight_find_sink(struct coresight_device *csdev, int *depth) > > child_dev = csdev->pdata->conns[i].child_dev; > if (child_dev) > - sink = coresight_find_sink(child_dev, &child_depth); > + sink = coresight_find_sink(child_dev, &child_depth, > + enabled); > > if (sink) > found_sink = coresight_select_best_sink(found_sink, > @@ -872,6 +889,10 @@ coresight_find_sink(struct coresight_device *csdev, int *depth) > } > > return_def_sink: > + /* Check if we need to return an enabled sink */ > + if (enabled && found_sink) > + if (!found_sink->activated) > + found_sink = NULL; > /* return found sink and depth */ > if (found_sink) > *depth = found_depth; > @@ -901,10 +922,30 @@ coresight_find_default_sink(struct coresight_device *csdev) > > /* look for a default sink if we have not found for this device */ > if (!csdev->def_sink) > - csdev->def_sink = coresight_find_sink(csdev, &depth); > + csdev->def_sink = coresight_find_sink(csdev, &depth, false); > return csdev->def_sink; > } > > +/** > + * coresight_find_enabled_sink: Find the suitable enabled sink > + * > + * @csdev: starting source to find a connected sink. > + * > + * Walks connections graph looking for a suitable sink to enable for the > + * supplied source. Uses CoreSight device subtypes and distance from source > + * to select the best sink. > + * > + * Used in cases where the CoreSight user (sysfs) has selected a sink. > + */ > +struct coresight_device * > +coresight_find_enabled_sink(struct coresight_device *csdev) > +{ > + int depth = 0; > + > + /* look for the enabled sink */ > + return coresight_find_sink(csdev, &depth, true); > +} > + Why this wrapper is required ? Could not coresight_find_sink() be used directly in the only caller i.e coresight_get_enabled_sink(). Besides, their names are really very similar and might lead to confusion. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel