From patchwork Thu Jul 16 17:57:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11668243 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 232281392 for ; Thu, 16 Jul 2020 18:01:38 +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 EAA2D20578 for ; Thu, 16 Jul 2020 18:01:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b40/t/Jx"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ANIWgaib" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAA2D20578 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=sl7uPOdarwj/Aqgr0uC9w1SIFvdokBUjNePpIeqYK48=; b=b40/t/JxWBWRZitn8Zq1HJ42V 0+epN+F0pyj5aoRATrUGoTQWJXDgCPd1d1cbM/3/FA3TOaBJ2VcnUKeA8/J+Za0zcnsr4EZlewK+C LrqTT6+o8OrzsghUmg4C9W9Dw0L9OJrjfWp5kIsZtLWwjnoCtoggE4kdo7a8G/+/eFbLteZ/TsTCP JhTmqyc+PtJrHbdOqSVwKS3KaTSjxVmMYUGJKnZiSWnkndP/12vLCZRD+G0lTjEQjs5DpDlfhXoCB l4OH+owCSgxh1llO7yR66/bvTc9d3AxdWe+lgK6op7+m2Z/28Yag+ISd0dxkvtG6KNOCcaA4B/urx +XC+eeQZg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw8AZ-0003yM-7x; Thu, 16 Jul 2020 17:59:43 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw88y-0003GL-5m for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 17:58:08 +0000 Received: by mail-pl1-x642.google.com with SMTP id 72so4202812ple.0 for ; Thu, 16 Jul 2020 10:58:04 -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=DqC/o+OJQTj83pbaJvj7SPqPQZtDsMDV59x7+pLCqqQ=; b=ANIWgaibkmjOeNnR+uMMVASzWtiRcUNiGA0UPCdZoeS+RhcTg1tUJ3Dw7SiZRSl6wT XsFdR3ANy9IoiUcSGxJWctobOM8x0JWn2k/RBY77KY8lhyoYeypK/KUGyK0tz/bgdiub Hw4mhFEmr9g9LqB1J0/6cXHLoOTlSDdf2qH5a5jYn2z4N2PcEqfxaI/WVA+06N6hrzeC mf2cCjMbsYn76nPYIPC8vOvefiFil8jCqgBUf04nFGV0GwftO64PBxvc8/l8Rdj0FB3l e22A7vonLd2I6Q6hDPgoGFVCSkwMLLOi2bs5IilvxYTiUGjOrh18K8PHtPiCoxyNo6WD 2WgQ== 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=DqC/o+OJQTj83pbaJvj7SPqPQZtDsMDV59x7+pLCqqQ=; b=p/f7VbBsP/m0ysaArW+Q9Gd6sv9sQPcsKPszV+K/MUDnyCHWMdWizGBnh0FZ53I6t1 nolboypp9BK3rq8Trv1WLcyBc30aEc3Wp8fdTrPqu3reyLDyJdCGIsXCN8kuM38QrjWA Uv7y8pn2fMhSC1lwg31J3zkkfaQo/Jju9/J/+6COQpg2PO+4mHkxxuhSqiVq4Cr0JVDj 1s/un/pGrIiEygsUtnHCTFn7hgezvSCnV4eHTQhu9kIdB8BtYQK+EbJwlTzqNcNf4GkN 4d8qnWpTBU71TvmPFHKHEgpU9X6LdXrgKK/DbyDSw5KcNG0N47TZVGQLRJ9ATJi8q6vu 9jfg== X-Gm-Message-State: AOAM533vaS3ojx8M+fsd16IXUPFxUNnBi5Fz5sd8rcAe8PDRR4xeqboH x+L6AcCdkiPtVTruOoVx4ecT5A== X-Google-Smtp-Source: ABdhPJwfkN3hNZVBDdOBEPPIKG1KUzpPvpCYs5beX3oWRVCB9y/gfDCvr/rhxRtHViFfD76VgJaq8g== X-Received: by 2002:a17:90a:350e:: with SMTP id q14mr6048446pjb.155.1594922282395; Thu, 16 Jul 2020 10:58:02 -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.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 10:58:01 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 12/17] coresight: tmc: Add shutdown callback for TMC ETR Date: Thu, 16 Jul 2020 11:57:41 -0600 Message-Id: <20200716175746.3338735-13-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_135804_378269_1D986063 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:642 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 Implement a shutdown callback to ensure ETR hardware is properly shutdown in reboot/shutdown path. This is required for ETR which has SMMU address translation enabled like on SC7180 SoC and few others. If the hardware is still accessing memory after SMMU translation is disabled as part of SMMU shutdown callback in system reboot or shutdown path, then IOVAs(I/O virtual address) which it was using will go on the bus as the physical addresses which might result in unknown crashes (NoC/interconnect errors). So we make sure from this shutdown callback that the ETR is shutdown before SMMU translation is disabled and device_link in SMMU driver will take care of ordering of shutdown callbacks such that SMMU shutdown callback is not called before any of its consumer shutdown callbacks. Signed-off-by: Sai Prakash Ranjan Signed-off-by: Mathieu Poirier --- .../hwtracing/coresight/coresight-tmc-etr.c | 2 +- drivers/hwtracing/coresight/coresight-tmc.c | 23 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 625882bc8b08..b29c2db94d96 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1110,7 +1110,7 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata) } -static void tmc_etr_disable_hw(struct tmc_drvdata *drvdata) +void tmc_etr_disable_hw(struct tmc_drvdata *drvdata) { __tmc_etr_disable_hw(drvdata); /* Disable CATU device if this ETR is connected to one */ diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 39fba1d16e6e..b13ce0daa572 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -538,6 +538,28 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) return ret; } +static void tmc_shutdown(struct amba_device *adev) +{ + unsigned long flags; + struct tmc_drvdata *drvdata = amba_get_drvdata(adev); + + spin_lock_irqsave(&drvdata->spinlock, flags); + + if (drvdata->mode == CS_MODE_DISABLED) + goto out; + + if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) + tmc_etr_disable_hw(drvdata); + + /* + * We do not care about coresight unregister here unlike remove + * callback which is required for making coresight modular since + * the system is going down after this. + */ +out: + spin_unlock_irqrestore(&drvdata->spinlock, flags); +} + static const struct amba_id tmc_ids[] = { CS_AMBA_ID(0x000bb961), /* Coresight SoC 600 TMC-ETR/ETS */ @@ -556,6 +578,7 @@ static struct amba_driver tmc_driver = { .suppress_bind_attrs = true, }, .probe = tmc_probe, + .shutdown = tmc_shutdown, .id_table = tmc_ids, }; builtin_amba_driver(tmc_driver); diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 71de978575f3..6e8d2dc33d17 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -268,6 +268,7 @@ ssize_t tmc_etb_get_sysfs_trace(struct tmc_drvdata *drvdata, /* ETR functions */ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata); int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata); +void tmc_etr_disable_hw(struct tmc_drvdata *drvdata); extern const struct coresight_ops tmc_etr_cs_ops; ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata, loff_t pos, size_t len, char **bufpp);