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=-11.5 required=3.0 tests=BAYES_00,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 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 3CEB3C43461 for ; Mon, 14 Sep 2020 19:37:51 +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 CBB5F207EA for ; Mon, 14 Sep 2020 19:37:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DI9g1Jju"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lWjXGK9H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBB5F207EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F7/O4ctu+nHTpQ6VAkB8z2TmCYKq2YZsxQOUauCieaM=; b=DI9g1JjuxgA8i6/ft7JL55UPB 5pigT2bsBIvHRhrr9HYEHKk+pDArid/WAeL/hEJOprVjV4UHLWhuvsFcLn++sLYOxT9QD1Vi0lRxG HY16OEfR4UQVh2SLkg529dhnJs0lCx09qo3EkUHmZHPvXX+qMDMW/AbpIILO3cPwN6UQB7wdFvKzr B8/1gEnev1orK8uQUupqXnJXWIca4Hcq5V6/AhHLY499SIBsbMn30iKuXqoQOwO9jSNG/QyBqz2s/ 4AfubPBx+h9QeDKrNTLPzdqmP0n526hQNUJ14hg5jD4VuxkyOvmmkkGq1D1HhYY7H+Ia4EIJrpt+W pqNv/YilQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHuGq-0001xK-QE; Mon, 14 Sep 2020 19:36:12 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHuGo-0001we-EE for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 19:36:11 +0000 Received: by mail-pj1-x1043.google.com with SMTP id kk9so409195pjb.2 for ; Mon, 14 Sep 2020 12:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hDwAYwnZRWS7M76wJPLzWc2a3HwfTP0lYn+DXqnGI/I=; b=lWjXGK9HlAgfcrtquu0tlyaaOVJ50U1oF4zSSMUeB8v/9D4jBcOiKODRepOV8IP7pe 2Wdx5Rw3Mdzs46dypHVAy04R8DYEgtsg2jv6ePbqIos33fzv6wJMRh3mzvo5RM7AmACX lkQJ81oIsMEaPVU624O7YRmqrGhw9lgPeElm0QiYsLPZ2QDzS5e8sgsYEcouFQ4UW9aL Ryktztu2yKJxQhpDQ61O5uJr22CSPv53JfSNHY/FukXw7bkIcJrQUy1YofkcyFRNV769 Sy8dlWp3lA/gGCfIEVmcS/E2A9z0akAfRfdBd01shrDMKyClQKPqj2zzgxXyntzXxPdm KCVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hDwAYwnZRWS7M76wJPLzWc2a3HwfTP0lYn+DXqnGI/I=; b=ngn52YMuQMD9RRfF8uyf0P1rwb2HN509Xk3LNeq2RB6YNTU6SD703WYT6WFoRLE03C BhTYLp4+QlVdmkzTdHCpDvq8hw2sUnLmeWHl6FTAwZR1aqwZbIrp75zp7nl0jl444MSH x8qXsKqElTz5K/9803d6WLOTKt8S/uI/iMHCBiG2AUMjdwaUsCiyxp7UrPvXwzSGWErW 8+yb3erfLJOk/K7syd0xZEPt4nWg4E14J1TrEr+NIO9jm983RIGaT+JONp8OG6EUlcE9 8VoLOHtT6GmptaX+kUMwAZYVTYmC5rGxSAabgJldL/+mHl1LqTx03DHMDhRvD5TSaNxf 1nYQ== X-Gm-Message-State: AOAM532BOdyx0yhuF+jSYDlhG2ErUJPytc1KaYNAays6sVPuU8fcShjd 84t5KbWSOMTWAzeKnF/wemsHKA== X-Google-Smtp-Source: ABdhPJxbAcVKgQz3YPUTUGsmO4Mq/RvgOs5YjWkBGvaiZUYOFNGBokAQ5OW4Vml6q/WkB2hKEVvVZA== X-Received: by 2002:a17:90a:e984:: with SMTP id v4mr822397pjy.202.1600112168192; Mon, 14 Sep 2020 12:36:08 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j19sm11580041pfe.108.2020.09.14.12.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 12:36:07 -0700 (PDT) Date: Mon, 14 Sep 2020 13:36:05 -0600 From: Mathieu Poirier To: Linu Cherian Subject: Re: [PATCH v4 2/2] coresight: Make sysFS functional on topologies with per core sink Message-ID: <20200914193605.GA3243721@xps15> References: <20200904024106.21478-1-lcherian@marvell.com> <20200904024106.21478-3-lcherian@marvell.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200904024106.21478-3-lcherian@marvell.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_153610_578797_133A5092 X-CRM114-Status: GOOD ( 30.87 ) 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@linaro.org, linuc.decode@gmail.com, linux-arm-kernel@lists.infradead.org, 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 Linu, On Fri, Sep 04, 2020 at 08:11:06AM +0530, 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. > > To fix this, coresight_get_enabled_sink API is updated to > do a connection based search starting from the given source, > instead of bus based search. > With sink selection using sysfs depecrated for perf interface, > provision for reset is removed as well in this API. > > Signed-off-by: Linu Cherian > --- > drivers/hwtracing/coresight/coresight-priv.h | 3 +- > drivers/hwtracing/coresight/coresight.c | 58 +++++++++----------- > 2 files changed, 29 insertions(+), 32 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h > index f2dc625ea585..5fe773c4d6cc 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -148,7 +148,8 @@ 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); > struct coresight_device *coresight_get_sink_by_id(u32 id); > struct coresight_device * > coresight_find_default_sink(struct coresight_device *csdev); > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index e9c90f2de34a..562dc3d5f5b2 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -540,50 +540,46 @@ struct coresight_device *coresight_get_sink(struct list_head *path) > return csdev; > } > > -static int coresight_enabled_sink(struct device *dev, const void *data) > +static struct coresight_device * > +coresight_find_enabled_sink(struct coresight_device *csdev) > { > - const bool *reset = data; > - struct coresight_device *csdev = to_coresight_device(dev); > + int i; > + struct coresight_device *sink; > > if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || > csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && > - csdev->activated) { > - /* > - * Now that we have a handle on the sink for this session, > - * disable the sysFS "enable_sink" flag so that possible > - * concurrent perf session that wish to use another sink don't > - * trip on it. Doing so has no ramification for the current > - * session. > - */ > - if (*reset) > - csdev->activated = false; > + csdev->activated) Indentation problem. > + return csdev; > > - return 1; > + /* > + * Recursively explore each port found on this element. > + */ > + for (i = 0; i < csdev->pdata->nr_outport; i++) { > + struct coresight_device *child_dev; > + > + child_dev = csdev->pdata->conns[i].child_dev; > + if (child_dev) > + sink = coresight_find_enabled_sink(child_dev); > + if (sink) > + return sink; > } > > - return 0; > + return NULL; > } > > /** > - * coresight_get_enabled_sink - returns the first enabled sink found on the bus > - * @deactivate: Whether the 'enable_sink' flag should be reset > - * > - * When operated from perf the deactivate parameter should be set to 'true'. > - * That way the "enabled_sink" flag of the sink that was selected can be reset, > - * allowing for other concurrent perf sessions to choose a different sink. > + * coresight_get_enabled_sink - returns the first enabled sink using > + * connection based search starting from the source reference > * > - * When operated from sysFS users have full control and as such the deactivate > - * parameter should be set to 'false', hence mandating users to explicitly > - * clear the flag. > + * @source: Coresight source device reference > */ > -struct coresight_device *coresight_get_enabled_sink(bool deactivate) > +struct coresight_device * > +coresight_get_enabled_sink(struct coresight_device *source) > { > - struct device *dev = NULL; > - > - dev = bus_find_device(&coresight_bustype, NULL, &deactivate, > - coresight_enabled_sink); > + if (!source) > + return NULL; > > - return dev ? to_coresight_device(dev) : NULL; > + return coresight_find_enabled_sink(source); > } > > static int coresight_sink_by_id(struct device *dev, const void *data) > @@ -992,7 +988,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. > */ With this patch the above comment is no longer relevant. Since you were nice enough to do the extra work I fixed both problem and applied your patches. Thanks, Mathieu > - sink = coresight_get_enabled_sink(false); > + sink = coresight_get_enabled_sink(csdev); > 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