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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 D54D1C433DB for ; Wed, 17 Mar 2021 19:33:28 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 3BE4664E42 for ; Wed, 17 Mar 2021 19:33:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BE4664E42 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc: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=XDGbfU71sWtrfEv1PlblOp5mYuLBpW0+d3ui5c9+s98=; b=QSWGl+nwcYQR6bDbyqIfWuz2S I4I818Qgo0KT/jlgrkPI1uPKuvfdg0DpmQlyYlr6hmc1s5gEVKRo319BkA5bDQFhbC65/zrDMWBa5 CcUgzaNkX3pv0udDYH4/LyxatfjfzpT5o3yKGTjIsWvsPhEkl/nxh5TYRSmWveSUxh+bABM4+dSOD HCVr/F3JRYiBOqJKDAP7bMakzRbouHE7QrMGwu+6KvuSBhypEjVh/T/uiXYVTQxYruBIjQC0QA74p nj3/0EJHDBcoBB1RidJ5td1HpRNGBVuIV6qSmS+yDSnRi66aye/7OhIIuxTZOzPGYxHskhV7XWVQQ ZXb60sJ+w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMbtQ-003on3-Gi; Wed, 17 Mar 2021 19:31:44 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMbtM-003omg-Po for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 19:31:42 +0000 Received: by mail-pj1-x1033.google.com with SMTP id k23-20020a17090a5917b02901043e35ad4aso3741012pji.3 for ; Wed, 17 Mar 2021 12:31:39 -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=gOINERHmieuwiuvM3DF70DRFGOBE0N4CRVVT5JEdKUI=; b=hdYVaEU8zYye5U51YYae9hQw/H5tgU5sTsFgUwWJMRIGDgXdKEILBxlSNnQcbhjOOw pdbVXjz5HGfp8c9ZICp3j9j4g8Ck4yqDDvCWrbxW/R2EqBcwJi6qzV1DxyqNjl9VS8lJ PWpfglBS1C0w4gcBXc9u97zXaWLQ3jj8uJXXA/EbRkFNRnxz9sus5S6p0LkljA97AHgA mJ2/pBXt1Q1J1FnHoB+jV4AR7EoA8O/p+22GwJZ73PEjYHHAKe2JCebs1sbzLOT/WM2z 1PtVguMbrflgAUSlp9NwaKk017iKH9XuE1KshG80dWALPxlcVYsnajhWXd59Ft5vK277 6MtA== 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=gOINERHmieuwiuvM3DF70DRFGOBE0N4CRVVT5JEdKUI=; b=b/R0i8N7qpi08SyqFR8+RfgPWLxKEU8Gp3+Zvy44lcvxQFKp04p0I/5BSNJugXmuM0 0vPHSGk6vxIYFXFJrfHVoDTOUmowoxfKI+uDlJMxoWOabmpYcQeqmF38I9ZNB7KRCeIF TkbD1mRNnjxTJzFOgXsG5kSNHMzBpKZoTGXo1gp+FShDy4Kck77qzAdR4WrYUF+57Utr caj3GQtMFUJnPmUGrO81SAHlP6rTnQJ+g969hE7fQikrfhVIv/wve9ML4okJLGia4lEX aKZPn27JPcEtv649fBD3u2jNq5JWrGoqKwB+JlEtcHKIfwMTP+LdcSfZGL2ICOuDHD88 tMOg== X-Gm-Message-State: AOAM533MZdw4JNJ2/SHE3tKxAYokJPOkthWe8qWB8pWFUI6fgHfKJpAY mlp1weml4oiqB8L5/ylhI2WvGg== X-Google-Smtp-Source: ABdhPJxT4hcGV1+KfLJYucco05CI4nKXUvozud9Gj0nWBK8A9PDOHr4G+M5XxT94PDL+XqPBwrLUoA== X-Received: by 2002:a17:90a:e00c:: with SMTP id u12mr393122pjy.133.1616009498414; Wed, 17 Mar 2021 12:31:38 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id s28sm21096325pfd.155.2021.03.17.12.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 12:31:37 -0700 (PDT) Date: Wed, 17 Mar 2021 13:31:36 -0600 From: Mathieu Poirier To: Suzuki K Poulose Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mike.leach@linaro.org, anshuman.khandual@arm.com, leo.yan@linaro.org Subject: Re: [PATCH v4 17/19] coresight: core: Add support for dedicated percpu sinks Message-ID: <20210317193136.GB1498234@xps15> References: <20210225193543.2920532-1-suzuki.poulose@arm.com> <20210225193543.2920532-18-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210225193543.2920532-18-suzuki.poulose@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_193140_934683_5B5B1A91 X-CRM114-Status: GOOD ( 35.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 On Thu, Feb 25, 2021 at 07:35:41PM +0000, Suzuki K Poulose wrote: > From: Anshuman Khandual > > Add support for dedicated sinks that are bound to individual CPUs. (e.g, > TRBE). To allow quicker access to the sink for a given CPU bound source, > keep a percpu array of the sink devices. Also, add support for building > a path to the CPU local sink from the ETM. > > This adds a new percpu sink type CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM. > This new sink type is exclusively available and can only work with percpu > source type device CORESIGHT_DEV_SUBTYPE_SOURCE_PROC. > > This defines a percpu structure that accommodates a single coresight_device > which can be used to store an initialized instance from a sink driver. As > these sinks are exclusively linked and dependent on corresponding percpu > sources devices, they should also be the default sink device during a perf > session. > > Outwards device connections are scanned while establishing paths between a > source and a sink device. But such connections are not present for certain > percpu source and sink devices which are exclusively linked and dependent. > Build the path directly and skip connection scanning for such devices. > > Cc: Mathieu Poirier > Cc: Mike Leach > Cc: Suzuki K Poulose > Tested-by: Suzuki K Poulose > Reviewed-by: Suzuki K Poulose > Signed-off-by: Anshuman Khandual > [Moved the set/get percpu sink APIs from TRBE patch to here] > Signed-off-by: Suzuki K Poulose > --- > Changes: > - Export methods to set/get percpu sinks for fixing module > build for TRBE > - Addressed coding style comments (Suzuki) > - Check status of _coresight_build_path() (Mathieu) > --- > drivers/hwtracing/coresight/coresight-core.c | 29 ++++++++++++++++++-- > drivers/hwtracing/coresight/coresight-priv.h | 3 ++ > include/linux/coresight.h | 12 ++++++++ > 3 files changed, 42 insertions(+), 2 deletions(-) Reviewed-by: Mathieu Poirier > > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c > index 0062c8935653..55c645616bf6 100644 > --- a/drivers/hwtracing/coresight/coresight-core.c > +++ b/drivers/hwtracing/coresight/coresight-core.c > @@ -23,6 +23,7 @@ > #include "coresight-priv.h" > > static DEFINE_MUTEX(coresight_mutex); > +DEFINE_PER_CPU(struct coresight_device *, csdev_sink); > > /** > * struct coresight_node - elements of a path, from source to sink > @@ -70,6 +71,18 @@ void coresight_remove_cti_ops(void) > } > EXPORT_SYMBOL_GPL(coresight_remove_cti_ops); > > +void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev) > +{ > + per_cpu(csdev_sink, cpu) = csdev; > +} > +EXPORT_SYMBOL_GPL(coresight_set_percpu_sink); > + > +struct coresight_device *coresight_get_percpu_sink(int cpu) > +{ > + return per_cpu(csdev_sink, cpu); > +} > +EXPORT_SYMBOL_GPL(coresight_get_percpu_sink); > + > static int coresight_id_match(struct device *dev, void *data) > { > int trace_id, i_trace_id; > @@ -784,6 +797,14 @@ static int _coresight_build_path(struct coresight_device *csdev, > if (csdev == sink) > goto out; > > + if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) && > + sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) { > + if (_coresight_build_path(sink, sink, path) == 0) { > + found = true; > + goto out; > + } > + } > + > /* Not a sink - recursively explore each port found on this element */ > for (i = 0; i < csdev->pdata->nr_outport; i++) { > struct coresight_device *child_dev; > @@ -999,8 +1020,12 @@ coresight_find_default_sink(struct coresight_device *csdev) > int depth = 0; > > /* 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); > + if (!csdev->def_sink) { > + if (coresight_is_percpu_source(csdev)) > + csdev->def_sink = per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev)); > + if (!csdev->def_sink) > + csdev->def_sink = coresight_find_sink(csdev, &depth); > + } > return csdev->def_sink; > } > > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h > index f5f654ea2994..ff1dd2092ac5 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -232,4 +232,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode); > void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev, > struct coresight_device *ect_csdev); > > +void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev); > +struct coresight_device *coresight_get_percpu_sink(int cpu); > + > #endif > diff --git a/include/linux/coresight.h b/include/linux/coresight.h > index 976ec2697610..8a3a3c199087 100644 > --- a/include/linux/coresight.h > +++ b/include/linux/coresight.h > @@ -50,6 +50,7 @@ enum coresight_dev_subtype_sink { > CORESIGHT_DEV_SUBTYPE_SINK_PORT, > CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, > CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, > + CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM, > }; > > enum coresight_dev_subtype_link { > @@ -428,6 +429,17 @@ static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 o > csa->write(val, offset, false, true); > } > > +static inline bool coresight_is_percpu_source(struct coresight_device *csdev) > +{ > + return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SOURCE) && > + (csdev->subtype.source_subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_PROC); > +} > + > +static inline bool coresight_is_percpu_sink(struct coresight_device *csdev) > +{ > + return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SINK) && > + (csdev->subtype.sink_subtype == CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM); > +} > #else /* !CONFIG_64BIT */ > > static inline u64 csdev_access_relaxed_read64(struct csdev_access *csa, > -- > 2.24.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel