Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1258126pxx; Tue, 27 Oct 2020 12:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznBX8fVqpn9HnUcdfmMKMoJHHEwzG0VYHabBZ26Nm+pHwA1hr0JVkfvF2+ar1qPizejW3J X-Received: by 2002:a17:907:11d0:: with SMTP id va16mr3707415ejb.22.1603825344543; Tue, 27 Oct 2020 12:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603825344; cv=none; d=google.com; s=arc-20160816; b=jIIIHdAPNseXX5T5cj3d7LAsL9Zrcp2YA5YZoUMZzG6pM1phvgze2CM5b5EEC+hwUP MP07hRMQIToglwvdUSEq3g/Zu9QT8JxS2+36tBZdGzNKtbxf+GxqiXD2mIfhGSYsfvre /Be92IntSm5leK13C5hiUQAjSVOylk+VtePpUusB7YWg3oJI5oRUsos2rW+c2srogsQu pxk3zq9CHi5AHiTPESfhqck2hIx5vXsQs2vP6ETd/lbEYQDiR3+S9c5oNAPCH8SH3WCu VkED2820vfNzfdlZIuAAeQ4QsC9tMmFweTaeajGqiiRh+RMqX0MVvTZXR2gSI6xaOLPB CQXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jLLas5K+XvhurGHJBOyb61SbzCpbv/pGF3SrtsXZkzg=; b=r8klThBYKF49Ki4cimvJTHSSjUyPeJTB0eMMBiFl2YCgH5rsq37EZnSKrGl3jY7kio jrZUZjbY4suqUn1PRpRBlnDuLDEKAVepfPKCNxuwnEMIFusEKMANOcRUfRBQLPu83lb9 VJ/3AtrNsJR13q6KNtGcrGdc0rnl8P5ybH8ahlAbNKFQfA+urWkik6cBs+dwH9szCkKF qc/bqHgdJ04bx7dRei/NvoAKihYzABrL2ODAiT/Pe6p2YhXPVcF0Q3Izptiw/C4/+tXq GRt13+bSDnuXEcc2hy5Vt6vS+HXQlXiRX0gyD8ZQiVJtrdehWQNxN2xn0sPlOTA0hJI+ 0TwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=StJ7Fj0N; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si1488483edb.31.2020.10.27.12.02.02; Tue, 27 Oct 2020 12:02:24 -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; dkim=pass header.i=@kernel.org header.s=default header.b=StJ7Fj0N; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501897AbgJ0AjC (ORCPT + 99 others); Mon, 26 Oct 2020 20:39:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:50342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409156AbgJZXuj (ORCPT ); Mon, 26 Oct 2020 19:50:39 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 94FDF21655; Mon, 26 Oct 2020 23:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756238; bh=NT/aR51GDyryf0mLFIHacQgtCPgCwaGzIKT6Fi97x8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=StJ7Fj0NNp7tdGXvlMfnpdoLPk6nWvD13MrjhX31wW5u8lNNsVdaB06j4uxTWSt5g /uNcaFpRgXog8cZns6RflBXzsXQy3lQuNEjjH7PyOHmswyJvWVKd7wXETHrzFSW9nB XqlmHW0oJNOE4ZRkKB0iKtql/dEign5HY4Ub97Xs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linu Cherian , Mathieu Poirier , Greg Kroah-Hartman , Sasha Levin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.9 075/147] coresight: Make sysfs functional on topologies with per core sink Date: Mon, 26 Oct 2020 19:47:53 -0400 Message-Id: <20201026234905.1022767-75-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linu Cherian [ Upstream commit 6d578258b955fc8888e1bbd9a8fefe7b10065a84 ] 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 [Fixed indentation problem and removed obsolete comment] Signed-off-by: Mathieu Poirier Link: https://lore.kernel.org/r/20200916191737.4001561-15-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/hwtracing/coresight/coresight-priv.h | 3 +- drivers/hwtracing/coresight/coresight.c | 62 +++++++++----------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index f2dc625ea5856..5fe773c4d6cc5 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 e9c90f2de34ac..bb4f9e0a5438d 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) + 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) @@ -988,11 +984,7 @@ int coresight_enable(struct coresight_device *csdev) goto out; } - /* - * 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); if (!sink) { ret = -EINVAL; goto out; -- 2.25.1