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=-15.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 751F4C433DF for ; Fri, 7 Aug 2020 17:09:21 +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 201432086A for ; Fri, 7 Aug 2020 17:09:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IFRmRDOi"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UV0tI48L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 201432086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7rTEFec/qY/PXTbNvvvsnuGmH6U2Tz+z4LYzEN9DEeY=; b=IFRmRDOiVcM7muLQ9IH+9FEcu 3jnHFeM79ehJd0naKo1c7A130Kkz57Zk+2brmNA7V+hykf0QCy/GHS6uOV4Lx6kTApPvv+j05KxYc vNZvb7WXP2JZaVGL5yEPrt2ldBQVsKOU258QADtMbf6gGVCs/SNvtLXE8FkgSc9Aen+b0S9Vrj4hH nPZCjLKw7jK3qRGbrYJ4bJEbP3TmAx9IkG2UGziX5RtD7pIMTMGzUvUctsVEH/boVf/+ZK5NIZD8G 7VsymXPGpAzgv18Op4AZ8Tnw8qSuzdTzNURbaEMp95S2LRAufC11s4G06shJ6zJEIXwVnHIlntuzG UXh4+M5xg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k45pu-0008Av-Hl; Fri, 07 Aug 2020 17:07:18 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k45pr-0008AN-V9 for linux-arm-kernel@lists.infradead.org; Fri, 07 Aug 2020 17:07:16 +0000 Received: by mail-ed1-x542.google.com with SMTP id i26so1770191edv.4 for ; Fri, 07 Aug 2020 10:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YSnyaTbow/kHvTFv1qocPXz/SCgkcitZitep8wcyeRA=; b=UV0tI48Lgn91Ilo3z3N7ywU0WceHkzeNPhLIxbpUJcIY1N59imOQG0pH7wU8i4SJHz UAC8HSP0eIyZRPUUKk9WdKtQkyGiN5HgQwc1ojIsFXuDV8xw1VzZzYwCZ+eCwUXI4o9q J97ip3COuydmlRCR5AstlygaUJuzTpWp8we6N/MYZsI2u4kor5CyyTo1nNtKjxDp87aJ pnDV3t9kGrUvIbuEkH0bOf9lcedEcxQ5LrT3+fwmLx8282vw4d8LRVvSI0RLjNICVaJU OD6YaGwX5pqla5RhspsiV2KPbJ7dvVvg6LQ8mj7MyqcDqD+rafP/ZjF5Wlr/1mLPIeK+ Qt4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YSnyaTbow/kHvTFv1qocPXz/SCgkcitZitep8wcyeRA=; b=V2loyIMeW8lR6kd5py//kfJWjox9SJs7fS5nECx55ud2JGP/p7QOyhu3KF+pxU0gop hic6nSWjYFFnVIPy57LTtVAEeEI84OKJLFW31gFnxkLpuf3DhgVx7X4FSZk3hfxel7O2 i0BRYbVefMFbL+Wli56jtrTxmrMHMIBKS7sOmkKT3Jlko03lHodOtB4xkOt65c4zM2pO 3hXwp8WRxs9kmtbEBg0N+LNQmrGRE17UQNfDMh4/bX181KdtlDNCfHoUhjVelBnfsq5h vTSKMOy43bTO2ql6vkuihLlcK5eszSqo0ULZtqH0yW0OUzU3cBj1wIna9+NzxsaMGUYH 64qQ== X-Gm-Message-State: AOAM530XEzL0zhHIEkH+154e6qx85uE9OrOFpUij9ebWMb3iNI+KI63r /0snUrfWl1MiBl8eeN6JICF3BANcBag+NsCjAQ0= X-Google-Smtp-Source: ABdhPJziW4TCqoRaThVYjpgqS5jJnj/sC73lTl2KkxeAxPFgMr9Bqg7ZY7qSR8icII9PEhhn43pGF3IvHm6pYeBus1c= X-Received: by 2002:a05:6402:1282:: with SMTP id w2mr9301443edv.183.1596820032678; Fri, 07 Aug 2020 10:07:12 -0700 (PDT) MIME-Version: 1.0 References: <20200801090950.19420-1-lcherian@marvell.com> In-Reply-To: <20200801090950.19420-1-lcherian@marvell.com> From: Linu Cherian Date: Fri, 7 Aug 2020 22:37:00 +0530 Message-ID: Subject: Re: [PATCH V2] coresight: Make sysFS functional on topologies with per core sink To: Linu Cherian X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200807_130716_048418_6C075261 X-CRM114-Status: GOOD ( 35.00 ) 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, Mike Leach , linux-arm-kernel@lists.infradead.org, Mathieu Poirier , suzuki.poulose@arm.com 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 Hi Mathieu, Any comments on this patch ? On Sat, Aug 1, 2020 at 2:40 PM Linu Cherian wrote: > > Coresight driver assumes sink is common across all the ETMs, > 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. > > 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); > +} > + > static int coresight_remove_sink_ref(struct device *dev, void *data) > { > struct coresight_device *sink = data; > @@ -992,7 +1033,7 @@ int coresight_enable(struct coresight_device *csdev) > * Search for a valid sink for this session but don't reset the > * "enable_sink" flag in sysFS. Users get to do that explicitly. > */ > - sink = coresight_get_enabled_sink(false); > + sink = coresight_get_enabled_sink(csdev, false); > if (!sink) { > ret = -EINVAL; > goto out; > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel