From patchwork Tue Nov 19 05:19:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 179705 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp171333ilf; Mon, 18 Nov 2019 21:52:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwVHjkBCGTBQoroctgE1klMaClkrGoh8jgk4ftxDrUEXWMku3fJ6Gdjr6k1L3Qa0AyWFINe X-Received: by 2002:a17:906:2508:: with SMTP id i8mr2935452ejb.323.1574142769724; Mon, 18 Nov 2019 21:52:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574142769; cv=none; d=google.com; s=arc-20160816; b=awn3O00uLyX6yN6CRzrF78s4tE2uV4PTmZrQprJTg4YbuQ6C1fjLbPVPVw+nyJRP1q Vi6vL1vTtUxk3yqvO/BCQSVsdcLy+21N1OjnGVqjKvSXv6En7BPczXyU2v5CO7tlHwSl T6c5IQ/ZUcFOGMea2ZgCpNStRPw12Ze31kobom7poumVM6Cx1QTx3j+Lg2Nk9ACL8XbL gT4TCOcFR/PlH9ZSSFr5D7E2oryIoqhxg5pafN/+OuWOkq94JD3XbzD/+p+CYvh8lsBf WjlZdd56vK5FQkiR8DA1F4lvvn5KdNUD4RymJVQR3sYbK1ApnM75ZNbSvh3UT48Pb1eb 8MbA== 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=EvGSaG5EWSG5vAEy04hLPeqUE+xgwnUH6+ln9iIoc84=; b=cTqQ7da51ktV3biRXAEeYD5OhpdPHfF8wt4ItZdBKexSrByEsjyi0+FFjH07Al448T JmJac3tgvgvcxMTk/aITe47rEQewW4NZx2JNlMjB3oIlxDhi+5u2wr0GgQafXocyjxIq qrTRroAGWHFQKnGEhvwmvWNaQciejs91m1hoK8W8GMuyF/uBeso4Krc6/N7x1Clv+5PG j8yPrWtJlbX9W75DNn/+euVgMvBJmDAKNgNdF8hutn+NVdhPNp70pJRa9migekIoP9+f 39tMFZVhVlzDzjCIdqa0Qig30k+QRFxcyyVGm2nurmVNMnOmQJzKQQAU0wiRvZSBXlP0 yyjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="EhNpAR/t"; 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 k26si13058899eja.58.2019.11.18.21.52.49; Mon, 18 Nov 2019 21:52:49 -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="EhNpAR/t"; 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 S1731947AbfKSFwq (ORCPT + 26 others); Tue, 19 Nov 2019 00:52:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:50516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731006AbfKSFwn (ORCPT ); Tue, 19 Nov 2019 00:52:43 -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 5DCE620721; Tue, 19 Nov 2019 05:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142761; bh=cj5u95BnEoI4lNCshidUefaPX9ljRH1R6f9BmPwhev4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EhNpAR/tFnLXSMXYn4Ahhg8jr5cGJSjVOizRfW6uflPHuFvWt4ex0i/dx3co79eZN 5XD0nwHjt4pkjk2UTjdInE6cjUc+GtKhWI0HkZZmHTyBbCHWsKSp3/J9X1rIPxVETs PICLHXwEeXM+t99+h89ex9/SK8wXdu9+2F1GbjMw= 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.14 191/239] coresight: Fix handling of sinks Date: Tue, 19 Nov 2019 06:19:51 +0100 Message-Id: <20191119051335.581613698@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@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 e571e4010dff0..366c1d493af35 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -140,12 +140,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; } @@ -347,8 +349,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 */