From patchwork Tue Nov 19 05:19:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 179721 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp181555ilf; Mon, 18 Nov 2019 22:03:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzCUdFxtV4G6B5CJilLQd0i+KXZrqQZ7e6bHS1OrZ/9+rKE+HPf9WYIZz7iwyNTcdFEmRH+ X-Received: by 2002:a17:906:411:: with SMTP id d17mr32183893eja.299.1574143424493; Mon, 18 Nov 2019 22:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574143424; cv=none; d=google.com; s=arc-20160816; b=dYrj34yK+cAq/TvvIKtdE+IcQ5/Wvvs10TYw+gzRwpJoNhuWRaFdbwbRsjl5Zac9wu b6U1K12VRgGncU43F5nUlQuQWSeXQHuBoiqhzRXX8EhxhZkZPtWyT+8+NbV+gVLXIfTd dEDraRRdp7Q1FYWy8c+PtHELPWgXJhZw9DhXwoxAb71pR7jkOIkQPo9bUiIuBSOtqT6s dPN0XjIIBtiplLxaoSKlhYw/fhOpRmM7T5pO+MDfnk+mU64AEkA26K9NCn2La19Pk8VR LF0Lc2uHtePBMBSg+e9AWQro2sA+it/RbXWXO650q7eDOv2x2tI0wf+lBAT96aPJy4se wOOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iS705d7nR8MDAqh46+IM7iP612AEHVYxXaMRWCFfxnM=; b=cboqPsO7mbmEtOlGQvryh7dYamapQ5TeSpPNnYY1PGWhuZN50zA0cG4hjR0CDR14YH PRDVonLYtXBV0h6uzx9nZbhAxhvgtucncJsk5p9p2M8ZFH1cSwdZUjPznB9ADKApvuzh QG4dghnNRa8lxJSJsoD3RvOTvwyKdG4FNh2qOFR0POX1vqvNsFiJre0kjcEOlQXiuS+c i/mJShzFGa7DxcwXI5aVbW6rYRoAl6jAzWAbeyyTx50/6KynyygNkNv2lYswTxwThzeu TheCfykn3tB4JCl1WXDvbdLNSTED2XUMBFJ5o/6ULkMym+Hr8vI6t0itgbufGHiYjtkr 7nTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j8yXsJDl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si13087332ejr.6.2019.11.18.22.03.44; Mon, 18 Nov 2019 22:03:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j8yXsJDl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729366AbfKSFjp (ORCPT + 26 others); Tue, 19 Nov 2019 00:39:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:33760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728329AbfKSFjm (ORCPT ); Tue, 19 Nov 2019 00:39:42 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B9FE7208C3; Tue, 19 Nov 2019 05:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574141980; bh=Y+QVWnNnofIfKEsSwHOQQRLh8sUpAcQANW9LqVyxVs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j8yXsJDlLEvCfUJ3yvUnORiYVpmv009jHcvLk+83IIfnggXjdWEksV//V7H3mTAPI 4tGiLLncnJ4WpkjwdO0R3oAacBbiLhQcDEq4OsBUAanTH8/Mo/ixq4ed4zMK5clFUr FUZCiIGYG++6rGitL/oBnGg3Vfh6i4eVi+vO4j2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathieu Poirier , Suzuki K Poulose , Sasha Levin Subject: [PATCH 4.19 345/422] coresight: Fix handling of sinks Date: Tue, 19 Nov 2019 06:19:02 +0100 Message-Id: <20191119051421.369859388@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051400.261610025@linuxfoundation.org> References: <20191119051400.261610025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose [ Upstream commit c71369de02b285d9da526a526d8f2affc7b17c59 ] The coresight components could be operated either in sysfs mode or in perf mode. For some of the components, the mode of operation doesn't matter as they simply relay the data to the next component in the trace path. But for sinks, they need to be able to provide the trace data back to the user. Thus we need to make sure that "mode" is handled appropriately. e.g, the sysfs mode could have multiple sources driving the trace data, while perf mode doesn't allow sharing the sink. The coresight_enable_sink() however doesn't really allow this check to trigger as it skips the "enable_sink" callback if the component is already enabled, irrespective of the mode. This could cause mixing of data from different modes or even same mode (in perf), if the sources are different. Also, if we fail to enable the sink while enabling a path (where sink is the first component enabled), we could end up in disabling the components in the "entire" path which were not enabled in this trial, causing disruptions in the existing trace paths. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/hwtracing/coresight/coresight.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 3e07fd335f8cf..c0dabbddc1e49 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -132,12 +132,14 @@ static int coresight_enable_sink(struct coresight_device *csdev, u32 mode) { int ret; - if (!csdev->enable) { - if (sink_ops(csdev)->enable) { - ret = sink_ops(csdev)->enable(csdev, mode); - if (ret) - return ret; - } + /* + * We need to make sure the "new" session is compatible with the + * existing "mode" of operation. + */ + if (sink_ops(csdev)->enable) { + ret = sink_ops(csdev)->enable(csdev, mode); + if (ret) + return ret; csdev->enable = true; } @@ -339,8 +341,14 @@ int coresight_enable_path(struct list_head *path, u32 mode) switch (type) { case CORESIGHT_DEV_TYPE_SINK: ret = coresight_enable_sink(csdev, mode); + /* + * Sink is the first component turned on. If we + * failed to enable the sink, there are no components + * that need disabling. Disabling the path here + * would mean we could disrupt an existing session. + */ if (ret) - goto err; + goto out; break; case CORESIGHT_DEV_TYPE_SOURCE: /* sources are enabled from either sysFS or Perf */