Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1355071pxy; Fri, 23 Apr 2021 06:21:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIhWYkK4A4JcMO+GfVqz+Mk1kJGPwzDL4nCUFw4xWwUWJecGp9v9jCEfO+C9s/KFtCeB6L X-Received: by 2002:a17:90a:9a84:: with SMTP id e4mr5673964pjp.220.1619184083924; Fri, 23 Apr 2021 06:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619184083; cv=none; d=google.com; s=arc-20160816; b=G1dL4KJ0IYI/G4TyQoJPZwwye2VMSXGhXXdstjRY3V+Zrv6eI8XMvAWTdia/v3ULeS 46CwKhIFT57Pf9SRHA1oSOHtmUsnZ53rQk75T2fJWGPOd9om4FyEqwOozmbiyhuVxypx 2r+dt9ELFGGeTqhPeUKnfmGWVwqajzLLLIqbsq3VGj3B9ONtV6cX4krIFV74y94thnv5 K3oOTNR+1U2oFM7nDX+0e7T1c56Vw+9Rp/s3Mx3hspsjfcuk2TzB7BMnY51jDg2GTU9H ++5HzeHTOAOWgz/dcA/WM4+y6pD8Mc97DDnQOy/8h+I6/Uz4xiSnkW1Qu97F9YnqYNXG mnwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=+i6h724soAhBsQZ0lMelesRqO7l027RL+/brRmOwxV8=; b=SUrQZUl9rI9ElRIdJqZ9cGErxKiriXYmccbBi34e66ddhhhYD/fQ7T7Qsn2x5EMB5B HBsOQbufNus6LeA5FC1avNsB5LcX5Qwm6+/R+hdB9gzKLgZlvbgxOYuBPgJyd8c1nmlq +NBx7ALdjXF91O7+LoZJRi8Pr2xukL8vwnAKM52tDh54p1D8RnI+B31L/2QiXvs1Nzzs 3Mj1R9UXwar6rTmgF1lOuktYTnx6x44xz7cXqsC4H0xUKFzcbECXiMnSe884WULYzhnp G2ogX8zalQgVe+uqACu/JD4fm66xgfI9/lP2xRsoDVa01/dJCN92TaTHskHSteDaaeuW vtPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si7178031pfu.103.2021.04.23.06.21.04; Fri, 23 Apr 2021 06:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231281AbhDWNU6 (ORCPT + 99 others); Fri, 23 Apr 2021 09:20:58 -0400 Received: from foss.arm.com ([217.140.110.172]:34716 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbhDWNU6 (ORCPT ); Fri, 23 Apr 2021 09:20:58 -0400 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 D140F1396; Fri, 23 Apr 2021 06:20:21 -0700 (PDT) Received: from [10.57.67.211] (unknown [10.57.67.211]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 112CF3F73B; Fri, 23 Apr 2021 06:20:19 -0700 (PDT) Subject: Re: [PATCH v1] coresight: add node to reset all coresight devices To: Tao Zhang , Mathieu Poirier , Alexander Shishkin Cc: Mike Leach , Leo Yan , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang , Mao Jinlong , Yuanfang Zhang References: <1619166578-28690-1-git-send-email-taozha@codeaurora.org> From: Suzuki K Poulose Message-ID: Date: Fri, 23 Apr 2021 14:20:18 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <1619166578-28690-1-git-send-email-taozha@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/04/2021 09:29, Tao Zhang wrote: > Add new reset_source_sink node to be able to disable all active > coresight devices. > In this way, we no longer need to manually disable all active > coresight devices one by one. After enabling multiple coresight > paths, users can reset their status more conveniently by this > node. > What is the use case here ? Why would you trigger a reset for all the sources/sink without gracefully completing any on-going sessions (including the perf ones, which are driven by the kernel perf layer) > This patch base on coresight-next repo > http://git.linaro.org/kernel/coresight.git/log/?h=next > > And this patch depends on the following patch > https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2551216.html Please post related patches as a series, possibly describing the overall problem that you are trying to solve, in the cover letter. > > Signed-off-by: Tingwei Zhang > Signed-off-by: Mao Jinlong > Signed-off-by: Tao Zhang > --- > drivers/hwtracing/coresight/coresight-core.c | 72 ++++++++++++++++++++++++---- > 1 file changed, 64 insertions(+), 8 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c > index 7dfadb6..0001b6c 100644 > --- a/drivers/hwtracing/coresight/coresight-core.c > +++ b/drivers/hwtracing/coresight/coresight-core.c > @@ -107,6 +107,23 @@ static int coresight_source_is_unique(struct coresight_device *csdev) > csdev, coresight_id_match); > } > > +static int coresight_reset_sink(struct device *dev, void *data) > +{ > + struct coresight_device *csdev = to_coresight_device(dev); > + > + if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || > + csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && > + csdev->activated) > + csdev->activated = false; Why is this needed, when the disabl_path() should have taken care of this ? > + > + return 0; > +} > + > +static void coresight_reset_all_sink(void) > +{ > + bus_for_each_dev(&coresight_bustype, NULL, NULL, coresight_reset_sink); > +} > + How can you disable all the active sinks when some of the sinks could be driven by perf ? > static int coresight_find_link_inport(struct coresight_device *csdev, > struct coresight_device *parent) > { > @@ -1137,7 +1154,7 @@ int coresight_enable(struct coresight_device *csdev) > } > EXPORT_SYMBOL_GPL(coresight_enable); > > -void coresight_disable(struct coresight_device *csdev) > +static void __coresight_disable(struct coresight_device *csdev) > { > int ret; > struct list_head *path = NULL; > @@ -1145,14 +1162,12 @@ void coresight_disable(struct coresight_device *csdev) > struct coresight_path *cspath_next = NULL; > struct coresight_device *src_csdev = NULL; > > - mutex_lock(&coresight_mutex); > - > ret = coresight_validate_source(csdev, __func__); > if (ret) > - goto out; > + return; > > if (!csdev->enable || !coresight_disable_source(csdev)) > - goto out; > + return; > > list_for_each_entry_safe(cspath, cspath_next, &cs_active_paths, link) { > src_csdev = coresight_get_source(cspath->path); > @@ -1165,12 +1180,16 @@ void coresight_disable(struct coresight_device *csdev) > } > } > if (path == NULL) > - goto out; > + return; > > coresight_disable_path(path); > coresight_release_path(path); > +} > > -out: > +void coresight_disable(struct coresight_device *csdev) > +{ > + mutex_lock(&coresight_mutex); > + __coresight_disable(csdev); > mutex_unlock(&coresight_mutex); > } > EXPORT_SYMBOL_GPL(coresight_disable); > @@ -1467,7 +1486,43 @@ int coresight_timeout(void __iomem *addr, u32 offset, int position, int value) > > return -EAGAIN; > } > -EXPORT_SYMBOL_GPL(coresight_timeout); Why ? > + > +static ssize_t reset_source_sink_store(struct bus_type *bus, > + const char *buf, size_t size) > +{ > + int ret = 0; > + unsigned long val; > + struct coresight_path *cspath = NULL; > + struct coresight_path *cspath_next = NULL; > + struct coresight_device *csdev; > + > + ret = kstrtoul(buf, 10, &val); > + if (ret) > + return ret; > + > + mutex_lock(&coresight_mutex); > + > + list_for_each_entry_safe(cspath, cspath_next, &cs_active_paths, link) { > + csdev = coresight_get_source(cspath->path); > + if (!csdev) > + continue; > + atomic_set(csdev->refcnt, 1); Is this safe ? > + __coresight_disable(csdev); > + } > + > + /* Reset all activated sinks */ > + coresight_reset_all_sink(); > + > + mutex_unlock(&coresight_mutex); > + return size; > +} > +static BUS_ATTR_WO(reset_source_sink); > + > +static struct attribute *coresight_reset_source_sink_attrs[] = { > + &bus_attr_reset_source_sink.attr, > + NULL, > +}; > +ATTRIBUTE_GROUPS(coresight_reset_source_sink); > > /* > * coresight_release_platform_data: Release references to the devices connected > @@ -1680,6 +1735,7 @@ EXPORT_SYMBOL_GPL(coresight_alloc_device_name); > > struct bus_type coresight_bustype = { > .name = "coresight", > + .bus_groups = coresight_reset_source_sink_groups, > }; > > static int __init coresight_init(void) >