From patchwork Fri Nov 22 10:27:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 179977 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp27057ilf; Fri, 22 Nov 2019 02:44:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxiFNcCACZo8CeoDQVhu3vSNbXykbbezs7K/nvx7XucNkmGh5WD/aD+/+ODU1QIXTURIPcc X-Received: by 2002:a05:6402:512:: with SMTP id m18mr229666edv.250.1574419480431; Fri, 22 Nov 2019 02:44:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574419480; cv=none; d=google.com; s=arc-20160816; b=cwM4W96WDQgHn8oVgQ480gieIekNLYH0oadf2bZbX3l1Zu7BxlzkgPsAAXtlLn7mYz eOzeEYOlX40f0uwqk5WybKSuRnAPhZf/R5Dy35kV9Rsli8QR2/NX8XMepxPqevBFLcCu 7tBlxX+nud8wyPeatST1Xb4EfvOEcUiteVDDDM6B2EM26014kNzWv6wF+anEUmnrcQ5i 1FoWhmKEZe1wZ9dDOYehVT1cTbu8XrHK42AGNmvAyLodCp8IfO/ilSC7xpSIwgexabh2 doncbiYhh2ptON6k5ru4R+WD125mgx69XEDjYxBDA0o5MhrVZKNAwQVONpy8INz6RVDt UPZw== 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=MEuiMn5xXhzKoAz8rqlknXvkGCSpLwXbW73JQTweZ44=; b=Gy9ewKX5dsIayZfvR+KRSZdZiopBP+7Y0kAflvvcq0w+aMGjrXFB3MM2rH7m5dWLh1 kFiag8J2p2jfroGf0hqSab/+k8vvSVE/OiKqzFDmvewAWXhcBsfJhWTwj7Hc1XQjQiBd d2SbQnSHrsQZbpllGE9AeDyfJTRcGAtS8AYXewdANsjIXlmaaohbxVOubuehpOUp+r+1 AwIUMTaxvQfCt2O8gXrcuUjwU6+18XaKLiTmYk2RvOQm1tBWPu5AUaPFoo+1dwVPEA/W D18VXgfoDfiGozPQAlBaacfvrT8bIF0thgfjIh2DLicZ8H49LlhBf8ZvDgRKm78zdyWw mMow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QWUdv5xx; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 c5si921847eds.263.2019.11.22.02.44.40; Fri, 22 Nov 2019 02:44:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=QWUdv5xx; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbfKVKoi (ORCPT + 15 others); Fri, 22 Nov 2019 05:44:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:50542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727740AbfKVKog (ORCPT ); Fri, 22 Nov 2019 05:44:36 -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 B1DD7205C9; Fri, 22 Nov 2019 10:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419474; bh=xfI8/dPVmCK1BenNrBBdSQzPPGYrx8ypbcs/wGBHDaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QWUdv5xx89L1G6ez34799qyJJ7g4yZn1VSaZ6Rd60b6BzqUvhStHEm1KQoqALU7ef nFnzfeWDa/4wA4e82Fnpy6CL0fYUTPBhU+BDzDL4IIoZYNU3liN3bW79vdkQrtHhp+ XJ/qS7EtaoC6RpmfSb4G1ixx68mWCIYF8Uop1HS4= 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.9 117/222] coresight: Fix handling of sinks Date: Fri, 22 Nov 2019 11:27:37 +0100 Message-Id: <20191122100911.607425908@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100830.874290814@linuxfoundation.org> References: <20191122100830.874290814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 398e44a9ec45d..5ffabc388630e 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; } @@ -331,8 +333,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 */