From patchwork Thu Jul 16 17:57:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11668231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B968D913 for ; Thu, 16 Jul 2020 18:00:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8CD8C205CB for ; Thu, 16 Jul 2020 18:00:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VW1MqmL7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fRQ/wqfS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CD8C205CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LWc1Dug8AMDaMeVtBeNUq+iawaixPO3jDSj9SiCEb+g=; b=VW1MqmL7s6Bv0GvpHWW2YfjMz KdEAW0xU4aGJPjSiGfRgE0RVwJOAThmTtvUlZOQ+gYnjpUHDwD8zrQzrBqUGTAUHIAE3FgTSqjbdE JjDrhkQsClCJYPMZzXOe8DnZtAnuEnaduO5S0ZeW/hVY1zEnMv37VuOqP74Cw6j96cXm2A4uweXRB 69w4Xhq2U/mLyKucly1w5tuZYKT/kb7KheIuaJ1CM6JgXVB5b9Ansjw26ttug5xmvIbO0h+slsj7O 1msIPdQo2U38tfdPdveBo2m1aSPlW7mm4BF4sGLu5qhOLqMECCl5olwc4bP7X0jlygyme7zUCxSOG euq3b6G4A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw89K-0003OH-TD; Thu, 16 Jul 2020 17:58:27 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw88q-0003Cn-0O for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 17:57:58 +0000 Received: by mail-pg1-x544.google.com with SMTP id m22so5193266pgv.9 for ; Thu, 16 Jul 2020 10:57:55 -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 :mime-version:content-transfer-encoding; bh=2d+sEY43gd12a7QTvlcUY239vONltJOS2Dk8APZEC9Y=; b=fRQ/wqfS8VOEP4J6LgXNcKiEC8tXyn+AhmVIr7BManDGhknpuFG7bq9cElAieDpW9m gg2K0kOLcev5l1nM5jMhOj6Kap+UWYKKe+L7+MM13mvwTK3ymWqpxESMwDbMBo+zf+e2 f7Bpu92ng7kCef8nJiWKEX0yRkk1rEk3KbPit9FGNFJ+MTyOujfebSwBF8ewKQducxH4 e/I220nxKOb2qcWN8eiSkS3RMZvXaTYaham1LrUoF90c7I/e0R/mq1n/+nuJMAgaW89Q KqT4lEOkE91IwLDOWwGX0qy54gsnaRBbcTFbnvA6U6TcXJ2UMVr5fExyNR4/6aijBjlU Y0qw== 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:mime-version:content-transfer-encoding; bh=2d+sEY43gd12a7QTvlcUY239vONltJOS2Dk8APZEC9Y=; b=Z4f0wIX3ZMqqz55vzAJtSJV3iCQIw6m1IPEczcO3BQo/ju6fnNJetLm0pvWXvbFIlF yU0RPdoB9sBoXPgrXTzLYJANmSnusuG2GIprXqPIGuJscuXq9rYJ9xylaQnaTueSBhdg BZinM52EG5Gn1VELDwhkQadrY16m2ps22ZhUal5REyGw/Ch6NdaigxE3wePdWao9KBll EDyjSetWi5SNPdc6uqVlVJBuIP6hdjEcKiBK+Bwn6MsEpcR/HLS/GXjCW/x2AkoJpIxz 64FHIoPuDgcPPQuCB4TJbpSYFDcH6F27jhqPzeqLog/GONLOK1vnFOAKNCbfuOg1zoCk tJWg== X-Gm-Message-State: AOAM5327OQ7zwrR84Yb1aRm10/zp1Zk47cbA58PvsJvRD0EFE+MZdeX1 L7p6gZ+uLoxYxyFTkCRR8owB2w== X-Google-Smtp-Source: ABdhPJxOYXuyTa/77jfnqwaGuTbTAe0IJ8c53ez6gutEkaTpUTp3g7eMHLAA/e50ehvWVEjkFNF8ng== X-Received: by 2002:a63:1f45:: with SMTP id q5mr5206433pgm.240.1594922274050; Thu, 16 Jul 2020 10:57:54 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 83sm5473253pfu.60.2020.07.16.10.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 10:57:53 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 05/17] coresight: replicator: Reset replicator if context is lost Date: Thu, 16 Jul 2020 11:57:34 -0600 Message-Id: <20200716175746.3338735-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200716175746.3338735-1-mathieu.poirier@linaro.org> References: <20200716175746.3338735-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_135757_182016_818BABBD X-CRM114-Status: GOOD ( 17.17 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saiprakash.ranjan@codeaurora.org, suzuki.poulose@arm.com, vulab@iscas.ac.cn, tingwei@codeaurora.org, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Sai Prakash Ranjan On some QCOM SoCs, replicators in Always-On domain loses its context as soon as the clock is disabled. Currently as a part of pm_runtime workqueue, clock is disabled after the replicator is initialized by amba_pm_runtime_suspend assuming that context is not lost which is not true for replicators with such limitations. So add a new property "qcom,replicator-loses-context" to identify such replicators and reset them. Suggested-by: Mike Leach Reviewed-by: Mike Leach Signed-off-by: Sai Prakash Ranjan Signed-off-by: Mathieu Poirier --- .../coresight/coresight-replicator.c | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index c619b456f55a..78acf29c49ca 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -32,12 +33,14 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); * @atclk: optional clock for the core parts of the replicator. * @csdev: component vitals needed by the framework * @spinlock: serialize enable/disable operations. + * @check_idfilter_val: check if the context is lost upon clock removal. */ struct replicator_drvdata { void __iomem *base; struct clk *atclk; struct coresight_device *csdev; spinlock_t spinlock; + bool check_idfilter_val; }; static void dynamic_replicator_reset(struct replicator_drvdata *drvdata) @@ -66,29 +69,43 @@ static int dynamic_replicator_enable(struct replicator_drvdata *drvdata, int inport, int outport) { int rc = 0; - u32 reg; - - switch (outport) { - case 0: - reg = REPLICATOR_IDFILTER0; - break; - case 1: - reg = REPLICATOR_IDFILTER1; - break; - default: - WARN_ON(1); - return -EINVAL; - } + u32 id0val, id1val; CS_UNLOCK(drvdata->base); - if ((readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0) == 0xff) && - (readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1) == 0xff)) + id0val = readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0); + id1val = readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1); + + /* + * Some replicator designs lose context when AMBA clocks are removed, + * so have a check for this. + */ + if (drvdata->check_idfilter_val && id0val == 0x0 && id1val == 0x0) + id0val = id1val = 0xff; + + if (id0val == 0xff && id1val == 0xff) rc = coresight_claim_device_unlocked(drvdata->base); + if (!rc) { + switch (outport) { + case 0: + id0val = 0x0; + break; + case 1: + id1val = 0x0; + break; + default: + WARN_ON(1); + rc = -EINVAL; + } + } + /* Ensure that the outport is enabled. */ - if (!rc) - writel_relaxed(0x00, drvdata->base + reg); + if (!rc) { + writel_relaxed(id0val, drvdata->base + REPLICATOR_IDFILTER0); + writel_relaxed(id1val, drvdata->base + REPLICATOR_IDFILTER1); + } + CS_LOCK(drvdata->base); return rc; @@ -239,6 +256,10 @@ static int replicator_probe(struct device *dev, struct resource *res) desc.groups = replicator_groups; } + if (fwnode_property_present(dev_fwnode(dev), + "qcom,replicator-loses-context")) + drvdata->check_idfilter_val = true; + dev_set_drvdata(dev, drvdata); pdata = coresight_get_platform_data(dev);