From patchwork Thu Sep 20 19:18:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 147161 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2377592ljw; Thu, 20 Sep 2018 12:20:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYhvYnA6Z7tDFHbuLLGU5Yq35fMT2UlJdmjrV0Y50bNOVOwGcUBZVU5cCRqgGBx35HaaRdg X-Received: by 2002:a63:2022:: with SMTP id g34-v6mr39076845pgg.235.1537471211207; Thu, 20 Sep 2018 12:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537471211; cv=none; d=google.com; s=arc-20160816; b=F2edQxRNlZlBl1MmJcKwlWzeqF9Hm9hLU+rS2uZye2S6OlGa9EPlpJro/XUAcRyL+g 4jfIiXKn9MxvYNrnL5nqoB7MjYy4H4Quz2nqcc7F+H18ALKx15LVY7y1+0aO5uyi5eGJ JuMngxd/zfQX2wP5YO3dhNaXO8ZCpfz1T07TrctL3a4EkTLVAA5VHVv0pqQTFd/zdit0 IjVrx2yeJZCR3WXiBM7CQfMmCMX0n7XVNVZ8e58fzeH0Ad4kivA+Zj9trbEWMSLDrtyE Ul9AX79v4ZEpWlNDnlvp5lM7qgE1BGqSWtJDCDw07WP3bJpYoezVbVTF67FWqTITxMmR G1fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nThcwxyyvT+dxtp2XwfLgsk1SXb+AwYpYqhOiuz4UJY=; b=0reYXRKDzkXfDQCSP7VAMuMeCk0LzLjraEzrMKZUA0RM5zIIYx8CPl8fB7HwjV/q68 cl+T13XHctzYPkLCopgbYAbP4LIE2D6sfvgX8ID6JtmVU4ZBBnk+FccBTeyGAqPo3bvh w2+60rFt4oFxR2MsvxRd3yhepY2ER602L/7XSnA641EeOTv1EvKNW6E0PwkuU8g/Sw4w 0ItvAuQ6yU8Urd9MsyTb7MrkvzBd6CFxS91HdjRvb3xXypokYwg+lMMLBdT4d4VAQVV5 z60IX1b9G3xfFOZPgndTJPQokzDloxw23iQTEreia9SxqXmdQQDflsq/77ySF7Kkuphi jtxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PDw6ejHT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si23815456plr.58.2018.09.20.12.20.10; Thu, 20 Sep 2018 12:20:11 -0700 (PDT) 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=@linaro.org header.s=google header.b=PDw6ejHT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389062AbeIUBER (ORCPT + 32 others); Thu, 20 Sep 2018 21:04:17 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37458 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388558AbeIUBEO (ORCPT ); Thu, 20 Sep 2018 21:04:14 -0400 Received: by mail-pl1-f195.google.com with SMTP id q5-v6so1323463pli.4 for ; Thu, 20 Sep 2018 12:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nThcwxyyvT+dxtp2XwfLgsk1SXb+AwYpYqhOiuz4UJY=; b=PDw6ejHT77dGv7IA9r4zrNG67uzeGLYsVDzLyJokTVXPGLah4uGW5mT+sCd1GZkaT5 /jGWrMSGmZq+/yGcDkhCei5zkCZLG/ggfzC5XSBgD4XZXno9iHBMJ0iOu9uBS47Gymcl mtS6WIbkqyMFZi6Cd61bPQwAVs7xw+1kINvt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nThcwxyyvT+dxtp2XwfLgsk1SXb+AwYpYqhOiuz4UJY=; b=syIpdKBqF0cHoh8NesAc1tLxzUX4gPkwQxK7ca/y4QFsHqPeW5qvEI4lnlm1ev1wj6 LbXY6JmU1khPlFIP+FQ3v8uz+tU/j9kBwVvqrr51UJS1ZH1eunQCdZSNj5N2D4NvsyVb IW/Jce8gW3EGXvVAbADQ8LgDYhkP4AxZefSedpxWyO2FGseOg4UiXRIX4bNVY1AYlgfO W4HzZhcC8X+Y5pvytgHkO7HiTvmRMf7wm/nSHCpzvmgeCk3PTnvha/Gd2a01FmAcyU7O qYvN+Xp7vqrsOzDgoMlpbu1Hn3zWLFeC0+nk+L6yOkUBOCDts1sDsi/apiQMgbBMq7ku Madw== X-Gm-Message-State: APzg51ACjnVJHMVItVm4QbZh8G2uJGO3KYrugdv2XYjKsDiYUFHHflx7 3lo3o1Hn5IOC3mqyqPhUZCXV2w== X-Received: by 2002:a17:902:bd07:: with SMTP id p7-v6mr40068448pls.32.1537471155181; Thu, 20 Sep 2018 12:19:15 -0700 (PDT) Received: from localhost.localdomain ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id k13-v6sm4424443pgf.37.2018.09.20.12.19.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 12:19:14 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 35/44] coresight: dynamic-replicator: Handle multiple connections Date: Thu, 20 Sep 2018 13:18:10 -0600 Message-Id: <1537471099-19781-36-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537471099-19781-1-git-send-email-mathieu.poirier@linaro.org> References: <1537471099-19781-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose When a replicator port is enabled, we block the traffic on the other port and route all traffic to the new enabled port. If there are two active trace sessions each targeting the two different paths from the replicator, the second session will disable the first session and route all the data to the second path. ETR / e.g, replicator \ ETB If CPU0 is operated in sysfs mode to ETR and CPU1 is operated in perf mode to ETB, depending on the order in which the replicator is enabled one device is blocked. Ideally we need trace-id for the session to make the right choice. That implies we need a trace-id allocation logic for the coresight subsystem and use that to route the traffic. The short term solution is to only manage the "target port" and leave the other port untouched. That leaves both the paths unaffected, except that some unwanted traffic may be pushed to the paths (if the Trace-IDs are not far enough), which is still fine and can be filtered out while processing rather than silently blocking the data. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- .../coresight/coresight-dynamic-replicator.c | 64 ++++++++++++++++------ 1 file changed, 47 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c index ebb80438f6a5..97f4673452cb 100644 --- a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c +++ b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c @@ -34,26 +34,42 @@ struct replicator_state { struct coresight_device *csdev; }; +/* + * replicator_reset : Reset the replicator configuration to sane values. + */ +static void replicator_reset(struct replicator_state *drvdata) +{ + CS_UNLOCK(drvdata->base); + + writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0); + writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1); + + CS_LOCK(drvdata->base); +} + static int replicator_enable(struct coresight_device *csdev, int inport, int outport) { + u32 reg; struct replicator_state *drvdata = dev_get_drvdata(csdev->dev.parent); + switch (outport) { + case 0: + reg = REPLICATOR_IDFILTER0; + break; + case 1: + reg = REPLICATOR_IDFILTER1; + break; + default: + WARN_ON(1); + return -EINVAL; + } + CS_UNLOCK(drvdata->base); - /* - * Ensure that the other port is disabled - * 0x00 - passing through the replicator unimpeded - * 0xff - disable (or impede) the flow of ATB data - */ - if (outport == 0) { - writel_relaxed(0x00, drvdata->base + REPLICATOR_IDFILTER0); - writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1); - } else { - writel_relaxed(0x00, drvdata->base + REPLICATOR_IDFILTER1); - writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0); - } + /* Ensure that the outport is enabled. */ + writel_relaxed(0x00, drvdata->base + reg); CS_LOCK(drvdata->base); dev_dbg(drvdata->dev, "REPLICATOR enabled\n"); @@ -63,15 +79,25 @@ static int replicator_enable(struct coresight_device *csdev, int inport, static void replicator_disable(struct coresight_device *csdev, int inport, int outport) { + u32 reg; struct replicator_state *drvdata = dev_get_drvdata(csdev->dev.parent); + switch (outport) { + case 0: + reg = REPLICATOR_IDFILTER0; + break; + case 1: + reg = REPLICATOR_IDFILTER1; + break; + default: + WARN_ON(1); + return; + } + CS_UNLOCK(drvdata->base); /* disable the flow of ATB data through port */ - if (outport == 0) - writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0); - else - writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1); + writel_relaxed(0xff, drvdata->base + reg); CS_LOCK(drvdata->base); @@ -156,7 +182,11 @@ static int replicator_probe(struct amba_device *adev, const struct amba_id *id) desc.groups = replicator_groups; drvdata->csdev = coresight_register(&desc); - return PTR_ERR_OR_ZERO(drvdata->csdev); + if (!IS_ERR(drvdata->csdev)) { + replicator_reset(drvdata); + return 0; + } + return PTR_ERR(drvdata->csdev); } #ifdef CONFIG_PM